From 2ef1c273bc0832dac2375e3ddf5ae42dbef6117e Mon Sep 17 00:00:00 2001 From: freakin23 Date: Mon, 16 Dec 2024 19:33:55 +0530 Subject: [PATCH 01/15] py sol for cyclic array --- solutions/platinum/cses-1191.mdx | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index 2945f85f45..541736eadc 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -124,5 +124,92 @@ int main() { printf("%d\n", r); } ``` + + + +```py +MAXN = 200000 +MAXL = 20 # approx maximum log base 2 of n + +# next[i][j] stores the start point of the next +# 2^j'th subarray if we choose this subarray starting at i +nxt = [[0] * MAXL for _ in range(MAXN)] + +# len[i][j] stores the total amount of elements between +# subarray starting at i and the next 2^j'th subarray +length = [[0] * MAXL for _ in range(MAXN)] + + +def len_between(x: int, y: int) -> int: + """ + :returns the number of elements between the subarray + starting at x and the next y subarrays + """ + total = 0 + for i in range(MAXL): + if y & (1 << i): + total += length[x][i] + x = nxt[x][i] + return total + + +def check(x: int) -> bool: + """ + :return true if there is a series of x subarrays + that uses the whole array + """ + for i in range(n): + if len_between(i, x) >= n: + return True + return False + + + +n, k = map(int, input().split()) +a = list(map(int, input().split())) + +total_sum = sum(a) + +# edge case: every element can go into one subarray +if k >= total_sum: + print(1) + exit(0) + +# two pointers to find each subarray range [l, r) +current_sum = 0 +r = 0 + +for l in range(n): + while current_sum + a[r % n] <= k: + current_sum += a[r % n] + r += 1 + + # initialize binary lifting arrays + nxt[l][0] = r % n + length[l][0] = r - l + + current_sum -= a[l] + +for j in range(1, MAXL): + for i in range(n): + nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] + # add lengths from the left and the right + length[i][j] = length[i][j - 1] + length[nxt[i][j - 1]][j - 1] + + +# binary search over the least amount of subarrays +# needed to cover the whole array +lo, hi = 0, n +while lo < hi - 1: + mid = (lo + hi) // 2 + if check(mid): + hi = mid + else: + lo = mid + +print(hi) +``` + + From e40a1afe9291d163c226e5c34b6aa1f92f53f63f Mon Sep 17 00:00:00 2001 From: freakin23 Date: Mon, 16 Dec 2024 19:37:30 +0530 Subject: [PATCH 02/15] add warning for py sol --- solutions/platinum/cses-1191.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index 541736eadc..af2186109b 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -128,6 +128,12 @@ int main() { + + +Due to Python's constant factor, the below solution TLEs on a couple test cases. + + + ```py MAXN = 200000 MAXL = 20 # approx maximum log base 2 of n From 6964d40ffb09b44d36539da03942196616682210 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Mon, 16 Dec 2024 19:43:52 +0530 Subject: [PATCH 03/15] add new edge case --- solutions/platinum/cses-1191.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index af2186109b..b17891a2e6 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -177,6 +177,11 @@ a = list(map(int, input().split())) total_sum = sum(a) +# edge case: each element create their own subarray +if k == 1: + print(n) + exit(0) + # edge case: every element can go into one subarray if k >= total_sum: print(1) From f7041a10d48df09184dd01a4815c70c52f769760 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Mon, 16 Dec 2024 19:45:55 +0530 Subject: [PATCH 04/15] update cses-1191 --- solutions/platinum/cses-1191.mdx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index b17891a2e6..26bf5aead0 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -171,7 +171,6 @@ def check(x: int) -> bool: return False - n, k = map(int, input().split()) a = list(map(int, input().split())) @@ -188,19 +187,19 @@ if k >= total_sum: exit(0) # two pointers to find each subarray range [l, r) -current_sum = 0 +curr_sum = 0 r = 0 for l in range(n): - while current_sum + a[r % n] <= k: - current_sum += a[r % n] + while curr_sum + a[r % n] <= k: + curr_sum += a[r % n] r += 1 # initialize binary lifting arrays nxt[l][0] = r % n length[l][0] = r - l - current_sum -= a[l] + curr_sum -= a[l] for j in range(1, MAXL): for i in range(n): From eedc9322f08d0bc7dfc5b0af6f0601be177410b3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:18:50 +0000 Subject: [PATCH 05/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- solutions/platinum/cses-1191.mdx | 72 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index 26bf5aead0..8a2de3ef5d 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -148,27 +148,27 @@ length = [[0] * MAXL for _ in range(MAXN)] def len_between(x: int, y: int) -> int: - """ - :returns the number of elements between the subarray - starting at x and the next y subarrays - """ - total = 0 - for i in range(MAXL): - if y & (1 << i): - total += length[x][i] - x = nxt[x][i] - return total + """ + :returns the number of elements between the subarray + starting at x and the next y subarrays + """ + total = 0 + for i in range(MAXL): + if y & (1 << i): + total += length[x][i] + x = nxt[x][i] + return total def check(x: int) -> bool: - """ - :return true if there is a series of x subarrays - that uses the whole array - """ - for i in range(n): - if len_between(i, x) >= n: - return True - return False + """ + :return true if there is a series of x subarrays + that uses the whole array + """ + for i in range(n): + if len_between(i, x) >= n: + return True + return False n, k = map(int, input().split()) @@ -183,40 +183,40 @@ if k == 1: # edge case: every element can go into one subarray if k >= total_sum: - print(1) - exit(0) + print(1) + exit(0) # two pointers to find each subarray range [l, r) curr_sum = 0 r = 0 for l in range(n): - while curr_sum + a[r % n] <= k: - curr_sum += a[r % n] - r += 1 + while curr_sum + a[r % n] <= k: + curr_sum += a[r % n] + r += 1 - # initialize binary lifting arrays - nxt[l][0] = r % n - length[l][0] = r - l + # initialize binary lifting arrays + nxt[l][0] = r % n + length[l][0] = r - l - curr_sum -= a[l] + curr_sum -= a[l] for j in range(1, MAXL): - for i in range(n): - nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] - # add lengths from the left and the right - length[i][j] = length[i][j - 1] + length[nxt[i][j - 1]][j - 1] + for i in range(n): + nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] + # add lengths from the left and the right + length[i][j] = length[i][j - 1] + length[nxt[i][j - 1]][j - 1] # binary search over the least amount of subarrays # needed to cover the whole array lo, hi = 0, n while lo < hi - 1: - mid = (lo + hi) // 2 - if check(mid): - hi = mid - else: - lo = mid + mid = (lo + hi) // 2 + if check(mid): + hi = mid + else: + lo = mid print(hi) ``` From e81a690b05aa744d9d5d739998af94fcc450f03e Mon Sep 17 00:00:00 2001 From: freakin23 Date: Tue, 17 Dec 2024 13:02:48 +0530 Subject: [PATCH 06/15] update Cyclic Array --- solutions/platinum/cses-1191.mdx | 244 ++++++++++--------------------- 1 file changed, 74 insertions(+), 170 deletions(-) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index 8a2de3ef5d..4bd409079c 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -2,126 +2,75 @@ id: cses-1191 source: CSES title: Cyclic Array -author: Chongtian Ma +author: Chongtian Ma, Rameez Parwez --- ## Explanation We can turn this into a graph problem, or more precisely, a tree. Let's add an edge from $u$ to $v$ if the maximum length of the subarray that starts at $v$ has to end at $u-1$, and so the next subarray must start at $u$. Remember the array is cyclic, so $u$ is not necessarily greater than $v$. This can be found using basic two pointers. We can iterate through the array with our left pointer and increment our right pointer if the sum between the two pointers is less than or equal to $k$. This will ensure that the subarray starting at the left pointer is as big as possible. -We can use binary lifting to find the start index of any next subarray in $\log(n)$ time. We can also track the number of elements between any two subarrays. - -Finally, we can binary search over the number of subarrays for the minimum. If we can use $x$ subarrays to cover the whole array, then we must also be able to use $x+1$ subarrays. - +We can use binary lifting for each possible starting position to determine the number of jumps required to cover exactly $n$ elements. + ## Implementation -**Time Complexity: $\mathcal O(n \log^2n)$** +**Time Complexity: $\mathcal O(n \log n)$** ```cpp -#include -using namespace std; -using ll = long long; +#include -const int MAXN = 2e5; -const int MAXL = 20; // approx maximum log base 2 of n +const int MAX_N = 2e5 + 1; +const int LOG = 20; /* * next[i][j] stores the start point of the next * 2^j'th subarray if we choose this subarray starting at i */ -array, MAXN> nxt; +int nxt[2 * MAX_N][LOG]; -/* - * len[i][j] stores the total amount of elements between - * subarray starting at i and the next 2^j'th subarray - */ -array, MAXN> len; +int arr[2 * MAX_N]; int main() { - ios::sync_with_stdio(false); - cin.tie(0); - - int n; - ll k; - scanf("%d%lld", &n, &k); - vector a(n); - for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } - - ll sum = 0; - for (int i = 0; i < n; i++) { sum += a[i]; } - - // edge case: every element can go into one subarray - if (k >= sum) { - printf("%d", 1); - return 0; - } - - // two pointers to find each subarray of the range [l,r) - sum = 0; - for (ll l = 0, r = 0; l < n; l++) { - while (sum + a[r % n] <= k) { - sum += a[r % n]; - r++; - } - - // initialize binary lifting arrays - nxt[l][0] = r % n; - len[l][0] = r - l; - - sum -= a[l]; - } - - for (int j = 1; j < MAXL; j++) { - for (int i = 0; i < n; i++) { - nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; - // add lengths from the left and the right - len[i][j] = len[i][j - 1] + len[nxt[i][j - 1]][j - 1]; - } - } - - /* - * returns the number of elements between the subarray - * starting at x and the next y subarrays - */ - auto len_between = [&](int x, int y) -> ll { - ll total = 0; - for (int i = 0; i < MAXL; i++) { - if (y & (1 << i)) { - total += len[x][i]; - x = nxt[x][i]; - } - } - - return total; - }; - - /* - * return true if there is a series of x subarrays - * that uses the whole array - */ - auto check = [&](int x) -> bool { - for (int i = 0; i < n; i++) { - if (len_between(i, x) >= n) { return true; } - } - return false; - }; - - /* - * binary search over the least amount of subarrays - * needed to cover the whole array - */ - int l = 0, r = n; - while (l < r - 1) { - int mid = l + (r - l) / 2; - if (check(mid)) { - r = mid; - } else l = mid; - } - - printf("%d\n", r); + int n; + long long k; + std::cin >> n >> k; + for (int i = 1; i <= n; i++) { + std::cin >> arr[i]; + arr[i + n] = arr[i]; + } + + for (int i = 1, j = 1; i <= 2 * n; i++) { + arr[i] += arr[i - 1]; + while (arr[i] - arr[j] > k) { + j++; + } + nxt[i][0] = j; // farthest position reachable from i + } + + // binary lifting transition + for (int j = 1; j < LOG; j++) { + for (int i = 1; i <= 2 * n; i++) { + nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; + } + } + + int res = n; + for (int i = n; i <= 2 * n; i++) { + int curr_res = 1; + int pos = i; + + // using binary lifting to simulate jumps and cover 'n' elements + for (int j = LOG - 1; j >= 0; j--) { + if (nxt[pos][j] > i - n) { + curr_res += (1 << j); + pos = nxt[pos][j]; + } + } + res = std::min(res, curr_res); + } + std::cout << res << '\n'; } ``` @@ -130,95 +79,50 @@ int main() { -Due to Python's constant factor, the below solution TLEs on a couple test cases. +Submit the solution in PyPy3 to avoid TLE. ```py -MAXN = 200000 -MAXL = 20 # approx maximum log base 2 of n +MAX_N = 200001 +LOG = 20 # next[i][j] stores the start point of the next # 2^j'th subarray if we choose this subarray starting at i -nxt = [[0] * MAXL for _ in range(MAXN)] - -# len[i][j] stores the total amount of elements between -# subarray starting at i and the next 2^j'th subarray -length = [[0] * MAXL for _ in range(MAXN)] - - -def len_between(x: int, y: int) -> int: - """ - :returns the number of elements between the subarray - starting at x and the next y subarrays - """ - total = 0 - for i in range(MAXL): - if y & (1 << i): - total += length[x][i] - x = nxt[x][i] - return total - - -def check(x: int) -> bool: - """ - :return true if there is a series of x subarrays - that uses the whole array - """ - for i in range(n): - if len_between(i, x) >= n: - return True - return False - +nxt = [[0] * LOG for _ in range(2 * MAX_N)] n, k = map(int, input().split()) -a = list(map(int, input().split())) - -total_sum = sum(a) - -# edge case: each element create their own subarray -if k == 1: - print(n) - exit(0) - -# edge case: every element can go into one subarray -if k >= total_sum: - print(1) - exit(0) +arr = list(map(int, input().split())) -# two pointers to find each subarray range [l, r) -curr_sum = 0 -r = 0 +arr = [0] + arr + arr -for l in range(n): - while curr_sum + a[r % n] <= k: - curr_sum += a[r % n] - r += 1 +j = 1 +for i in range(1, 2 * n + 1): + arr[i] += arr[i - 1] + while arr[i] - arr[j] > k: + j += 1 - # initialize binary lifting arrays - nxt[l][0] = r % n - length[l][0] = r - l + nxt[i][0] = j # farthest position reachable from i - curr_sum -= a[l] +# binary lifting transition +for j in range(1, LOG): + for i in range(1, 2 * n + 1): + nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] -for j in range(1, MAXL): - for i in range(n): - nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] - # add lengths from the left and the right - length[i][j] = length[i][j - 1] + length[nxt[i][j - 1]][j - 1] +res = n +for i in range(n, 2 * n + 1): + curr_res = 1 + pos = i + # using binary lifting to simulate jumps and cover 'n' elements + for j in range(LOG - 1, -1, -1): + if nxt[pos][j] > i - n: + curr_res += (1 << j) + pos = nxt[pos][j] -# binary search over the least amount of subarrays -# needed to cover the whole array -lo, hi = 0, n -while lo < hi - 1: - mid = (lo + hi) // 2 - if check(mid): - hi = mid - else: - lo = mid + res = min(res, curr_res) -print(hi) +print(res) ``` From 85fcda23006930be0b3ddc34288019ec45b7943b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 07:34:39 +0000 Subject: [PATCH 07/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- solutions/platinum/cses-1191.mdx | 102 +++++++++++++++---------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/solutions/platinum/cses-1191.mdx b/solutions/platinum/cses-1191.mdx index 4bd409079c..aed27800e2 100644 --- a/solutions/platinum/cses-1191.mdx +++ b/solutions/platinum/cses-1191.mdx @@ -10,7 +10,7 @@ author: Chongtian Ma, Rameez Parwez We can turn this into a graph problem, or more precisely, a tree. Let's add an edge from $u$ to $v$ if the maximum length of the subarray that starts at $v$ has to end at $u-1$, and so the next subarray must start at $u$. Remember the array is cyclic, so $u$ is not necessarily greater than $v$. This can be found using basic two pointers. We can iterate through the array with our left pointer and increment our right pointer if the sum between the two pointers is less than or equal to $k$. This will ensure that the subarray starting at the left pointer is as big as possible. We can use binary lifting for each possible starting position to determine the number of jumps required to cover exactly $n$ elements. - + ## Implementation **Time Complexity: $\mathcal O(n \log n)$** @@ -33,44 +33,40 @@ int nxt[2 * MAX_N][LOG]; int arr[2 * MAX_N]; int main() { - int n; - long long k; - std::cin >> n >> k; - for (int i = 1; i <= n; i++) { - std::cin >> arr[i]; - arr[i + n] = arr[i]; - } - - for (int i = 1, j = 1; i <= 2 * n; i++) { - arr[i] += arr[i - 1]; - while (arr[i] - arr[j] > k) { - j++; - } - nxt[i][0] = j; // farthest position reachable from i - } - - // binary lifting transition - for (int j = 1; j < LOG; j++) { - for (int i = 1; i <= 2 * n; i++) { - nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; - } - } - - int res = n; - for (int i = n; i <= 2 * n; i++) { - int curr_res = 1; - int pos = i; - - // using binary lifting to simulate jumps and cover 'n' elements - for (int j = LOG - 1; j >= 0; j--) { - if (nxt[pos][j] > i - n) { - curr_res += (1 << j); - pos = nxt[pos][j]; - } - } - res = std::min(res, curr_res); - } - std::cout << res << '\n'; + int n; + long long k; + std::cin >> n >> k; + for (int i = 1; i <= n; i++) { + std::cin >> arr[i]; + arr[i + n] = arr[i]; + } + + for (int i = 1, j = 1; i <= 2 * n; i++) { + arr[i] += arr[i - 1]; + while (arr[i] - arr[j] > k) { j++; } + nxt[i][0] = j; // farthest position reachable from i + } + + // binary lifting transition + for (int j = 1; j < LOG; j++) { + for (int i = 1; i <= 2 * n; i++) { nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; } + } + + int res = n; + for (int i = n; i <= 2 * n; i++) { + int curr_res = 1; + int pos = i; + + // using binary lifting to simulate jumps and cover 'n' elements + for (int j = LOG - 1; j >= 0; j--) { + if (nxt[pos][j] > i - n) { + curr_res += (1 << j); + pos = nxt[pos][j]; + } + } + res = std::min(res, curr_res); + } + std::cout << res << '\n'; } ``` @@ -98,29 +94,29 @@ arr = [0] + arr + arr j = 1 for i in range(1, 2 * n + 1): - arr[i] += arr[i - 1] - while arr[i] - arr[j] > k: - j += 1 + arr[i] += arr[i - 1] + while arr[i] - arr[j] > k: + j += 1 - nxt[i][0] = j # farthest position reachable from i + nxt[i][0] = j # farthest position reachable from i # binary lifting transition for j in range(1, LOG): - for i in range(1, 2 * n + 1): - nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] + for i in range(1, 2 * n + 1): + nxt[i][j] = nxt[nxt[i][j - 1]][j - 1] res = n for i in range(n, 2 * n + 1): - curr_res = 1 - pos = i + curr_res = 1 + pos = i - # using binary lifting to simulate jumps and cover 'n' elements - for j in range(LOG - 1, -1, -1): - if nxt[pos][j] > i - n: - curr_res += (1 << j) - pos = nxt[pos][j] + # using binary lifting to simulate jumps and cover 'n' elements + for j in range(LOG - 1, -1, -1): + if nxt[pos][j] > i - n: + curr_res += 1 << j + pos = nxt[pos][j] - res = min(res, curr_res) + res = min(res, curr_res) print(res) ``` From 88b3b49d9c8d04a8af458a9739d19f08b6749341 Mon Sep 17 00:00:00 2001 From: TheGamingMousse <68484800+TheGamingMousse@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:21:22 -0800 Subject: [PATCH 08/15] Exponentiation II Formatting Change --- solutions/gold/{cses-1095.mdx => cses-1712.mdx} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename solutions/gold/{cses-1095.mdx => cses-1712.mdx} (89%) diff --git a/solutions/gold/cses-1095.mdx b/solutions/gold/cses-1712.mdx similarity index 89% rename from solutions/gold/cses-1095.mdx rename to solutions/gold/cses-1712.mdx index 989edcd812..91e0bb0c57 100644 --- a/solutions/gold/cses-1095.mdx +++ b/solutions/gold/cses-1712.mdx @@ -7,7 +7,9 @@ author: Ryan Chou ## Explanation -[Fermat's Little Theorem](/gold/modular) tells us that $a^{p - 1} \equiv 1 \pmod{p}$, so we can calculate $a^{b^c \pmod{1e9 + 7 - 1}} \pmod{1e9+7}$ with modular exponentiation. +Let $M = 10^{9} + 7$. + +[Fermat's Little Theorem](/gold/modular) tells us that $a^{p - 1} \equiv 1 \pmod{p}$, so we can calculate $a^{b^c \pmod{M - 1}} \pmod{M}$ with modular exponentiation. ## Implementation From 2d7470ec78331b65411e98c99fb70b726b0dab85 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Thu, 19 Dec 2024 20:43:18 +0530 Subject: [PATCH 09/15] minor add --- content/6_Advanced/String_Search.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/6_Advanced/String_Search.mdx b/content/6_Advanced/String_Search.mdx index e2a8da72fa..01ef02637b 100644 --- a/content/6_Advanced/String_Search.mdx +++ b/content/6_Advanced/String_Search.mdx @@ -523,7 +523,7 @@ For example, when transitioning from $i$ to $i+1$ in $S$ there only are two choi 1. If $node$ does have an outgoing edge with letter $S_{i+1}$, then move down the edge. 2. Otherwise, follow the failure link of $S_i$ and transition to letter $S_{i+1}$ from there. -The image below depicts how the structure looks like for the words $[a, ag, c, caa, gag, gc]$. +The image below depicts how the structure looks like for the words $[a, ag, c, caa, gag, gc, gca]$.
![Trie](./Trie.png) From f0dda5438c1a02a7309a2b05adb18c11500bbd54 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Thu, 19 Dec 2024 21:28:04 +0530 Subject: [PATCH 10/15] formatting --- content/6_Advanced/String_Search.mdx | 50 +++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/content/6_Advanced/String_Search.mdx b/content/6_Advanced/String_Search.mdx index 01ef02637b..bd49c1c229 100644 --- a/content/6_Advanced/String_Search.mdx +++ b/content/6_Advanced/String_Search.mdx @@ -248,6 +248,26 @@ print(len(s)) + + + + + + + **Manacher's Algorithm** functions similarly to the **Z-Algorithm**. It determines the longest palindrome centered at each character. @@ -356,25 +376,6 @@ int main() { - - - - - - If s[l, r] is a palindrome, then s[l+1, r-1] is as well. @@ -407,6 +408,12 @@ character palindrome must have been created from a palindrome of length $-1$ + + + + + + A trie is a tree-like data structure that stores strings. Each node is a string, and each edge is a character. The root is the empty string, and every node is represented by the characters along the path from the root to that node. @@ -481,11 +488,6 @@ int main() { - - - - - From e3e8172cacd5f878c02b01ac1a798ee6ae96f612 Mon Sep 17 00:00:00 2001 From: Benjamin Qi Date: Fri, 20 Dec 2024 16:02:35 -0500 Subject: [PATCH 11/15] Update Contests.mdx remove out of date info --- content/1_General/Contests.mdx | 38 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/content/1_General/Contests.mdx b/content/1_General/Contests.mdx index d1f1b29a2b..7765d249d9 100644 --- a/content/1_General/Contests.mdx +++ b/content/1_General/Contests.mdx @@ -7,7 +7,7 @@ description: 'Well-known programming contests and helpful tools for programming ## Frequent Contests -These websites hold contests that I frequently participate in. +These websites hold contests that I've often participated in. - [AtCoder](https://beta.atcoder.jp/contests/archive) - - Probably the highest quality - - Beginner / Regular Contests: 4 or 6 problems, ~100 min - - Grand Contests: 6 problems, 110 - 150 min - - Difficulty isn't always reasonable ... + - Beginner, Regular, and Grand contests, 100-180 min - [Codeforces](http://codeforces.com/problemset) - - Div 1-4: 5-6 problems (with some variations), 2 to 2.5 hrs -- [Topcoder](https://www.topcoder.com/my-dashboard/) - - Div 2, Div 1 - - 75 min coding, 15 min challenge - - Solutions only tested after contest! + - Div 1-4, 2-3 hrs - [DMOJ: Modern Online Judge](http://dmoj.ca/) - - at least one contest every month during school year - - practice implementation!! - - + - usually 3 hrs, can choose your start time within a window (like USACO) ## Other Websites - - misc ICPC contests - - Indonesian + 2-2.5 hrs + + + misc ICPC contests (5 hrs) - monthly Long, Lunchtime, Cookoff + monthly Starters -These platforms no longer actively hold contests, but might be worth a look. +These platforms no longer actively hold contests, but it might be worth looking +at past problems. see archive + + Two divisions. 75 min coding, 15 min challenge phases. Solutions only tested after contest. + ## Onsite Finals (Individual) -Let me know if there's something else I should try to qualify for! - recently updated - Date: Fri, 20 Dec 2024 16:03:39 -0500 Subject: [PATCH 12/15] Update Contests.mdx --- content/1_General/Contests.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/1_General/Contests.mdx b/content/1_General/Contests.mdx index 7765d249d9..cbd1e704c3 100644 --- a/content/1_General/Contests.mdx +++ b/content/1_General/Contests.mdx @@ -38,7 +38,7 @@ These websites hold contests that I've often participated in. ## Other Websites - + 2-2.5 hrs From 65949d7b88dac13a72847ed3705e0a8732df4524 Mon Sep 17 00:00:00 2001 From: Vincent You <113566592+Vinceyou1@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:30:15 -0600 Subject: [PATCH 13/15] December Contest Banner --- src/components/TopNavigationBar/TopNavigationBar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TopNavigationBar/TopNavigationBar.tsx b/src/components/TopNavigationBar/TopNavigationBar.tsx index 44d72378ad..ac54f1e8dc 100644 --- a/src/components/TopNavigationBar/TopNavigationBar.tsx +++ b/src/components/TopNavigationBar/TopNavigationBar.tsx @@ -138,9 +138,9 @@ export default function TopNavigationBar({ {!hidePromoBar && ( <> )} From a7b1fa0d604e8b924235191658b6d51dd1b33048 Mon Sep 17 00:00:00 2001 From: Dong Liu Date: Sun, 22 Dec 2024 09:46:34 -0800 Subject: [PATCH 14/15] Update CODEOWNERS --- CODEOWNERS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 116b1ff783..76a36f2b9a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -10,9 +10,9 @@ /solutions/silver/ @SansPapyrus683 @ryanchou-dev /content/4_Gold/ @dongliu0426 @envyaims /solutions/gold/ @dongliu0426 @envyaims -/content/5_Plat/ @dustin-miao @dongliu0426 -/solutions/platinum/ @dustin-miao @dongliu0426 -/content/6_Advanced/ @dustin-miao @dongliu0426 -/solutions/advanced/ @dustin-miao @dongliu0426 +/content/5_Plat/ @dustin-miao @dongliuu +/solutions/platinum/ @dustin-miao @dongliuu +/content/6_Advanced/ @dustin-miao @dongliuu +/solutions/advanced/ @dustin-miao @dongliuu /content/extraProblems.json @SansPapyrus683 @envyaims /content/team/ @SansPapyrus683 @ryanchou-dev From ade45f7e9529356b670e2cd062754a7669658d4b Mon Sep 17 00:00:00 2001 From: Dong Liu Date: Sun, 22 Dec 2024 09:47:54 -0800 Subject: [PATCH 15/15] Update CODEOWNERS --- CODEOWNERS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 76a36f2b9a..7a314e15b8 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,11 +8,11 @@ /solutions/bronze/ @SansPapyrus683 @ryanchou-dev /content/3_Silver/ @SansPapyrus683 @ryanchou-dev /solutions/silver/ @SansPapyrus683 @ryanchou-dev -/content/4_Gold/ @dongliu0426 @envyaims -/solutions/gold/ @dongliu0426 @envyaims -/content/5_Plat/ @dustin-miao @dongliuu -/solutions/platinum/ @dustin-miao @dongliuu -/content/6_Advanced/ @dustin-miao @dongliuu -/solutions/advanced/ @dustin-miao @dongliuu +/content/4_Gold/ @dongliuu @envyaims +/solutions/gold/ @dongliuu @envyaims +/content/5_Plat/ @dongliuu +/solutions/platinum/ @dongliuu +/content/6_Advanced/ @dongliuu +/solutions/advanced/ @dongliuu /content/extraProblems.json @SansPapyrus683 @envyaims /content/team/ @SansPapyrus683 @ryanchou-dev