From 7f5bcbc6a42ce5433f06dbb452ce5605ba260eac Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 19:37:25 +0530 Subject: [PATCH 01/18] update conclusion.problems.json --- content/2_Bronze/Conclusion.problems.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/2_Bronze/Conclusion.problems.json b/content/2_Bronze/Conclusion.problems.json index 9490a341a9..81f783bad9 100644 --- a/content/2_Bronze/Conclusion.problems.json +++ b/content/2_Bronze/Conclusion.problems.json @@ -47,8 +47,7 @@ "isStarred": false, "tags": ["Greedy"], "solutionMetadata": { - "kind": "autogen-label-from-site", - "site": "CF" + "kind": "internal" } }, { From 76980e8095ac954de8f1fdf3ba6fc4740c9e82e2 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 19:39:41 +0530 Subject: [PATCH 02/18] update cf-1624D --- solutions/bronze/cf-1624D.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 solutions/bronze/cf-1624D.mdx diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx new file mode 100644 index 0000000000..4d406f5968 --- /dev/null +++ b/solutions/bronze/cf-1624D.mdx @@ -0,0 +1,9 @@ +--- +id: cf-1624D +source: CF +title: Palindromes Coloring +author: Sōsuke +--- + +[Official Editorial](https://codeforces.com/blog/entry/98942) + From 384baa0e2084d2e2558cd062c6abe1c5f1022473 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 19:40:29 +0530 Subject: [PATCH 03/18] add layout --- solutions/bronze/cf-1624D.mdx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 4d406f5968..ca90090e3c 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -7,3 +7,26 @@ author: Sōsuke [Official Editorial](https://codeforces.com/blog/entry/98942) +## Explanation + + +## Implementation + + + + +```cpp + +``` + + + + +```py + + +``` + + + + From ca39522a1ad67be2494704d456bc7af9b6e4a7e4 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 19:51:10 +0530 Subject: [PATCH 04/18] update explanation --- solutions/bronze/cf-1624D.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index ca90090e3c..c0a84b5d71 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -9,6 +9,9 @@ author: Sōsuke ## Explanation +We can greedily solve this problem by first forming palindromic pairs from identical characters. +We add one pair each of the `k` palindromes we want to build, as long as we have `k` pairs available. +Once we are done adding pairs, we can still add one more character to the middle of each palindrome if there are atleast `k` individual characters remaining. ## Implementation From fce99c8413ccf15de5c5f0fd957161557adadfd6 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 20:00:28 +0530 Subject: [PATCH 05/18] update time complexity --- solutions/bronze/cf-1624D.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index c0a84b5d71..13874faf86 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -15,6 +15,8 @@ Once we are done adding pairs, we can still add one more character to the middle ## Implementation +**Time Complexity:** $\mathcal{O}(N)$ + From 0e9337fea1ce05439f12e95b1f12ac4a09747b6a Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 20:00:43 +0530 Subject: [PATCH 06/18] update cpp solution --- solutions/bronze/cf-1624D.mdx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 13874faf86..0020e39495 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -21,6 +21,37 @@ Once we are done adding pairs, we can still add one more character to the middle ```cpp +#include + +using std::cout; + +int main() { + int test_num; + std::cin >> test_num; + while (test_num--) { + + int n, k; + std::string st; + std::array cnt {0}; + std::cin >> n >> k >> st; + + for (char x : st) { + cnt[x - 'a']++; + } + + int pairs_cnt = 0, odd_cnt = 0; + for (int i = 0; i < 26; i++) { + pairs_cnt += cnt[i] / 2; + odd_cnt += (cnt[i] % 2 == 1); + } + + int res = 2 * (pairs_cnt / k); + odd_cnt += 2 * (pairs_cnt % k); + res += (odd_cnt >= k); + + cout << res << '\n'; + } +} ``` From c73610592d6533706d6dad86f30b44a4a86bbf69 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 20:05:24 +0530 Subject: [PATCH 07/18] update py solution --- solutions/bronze/cf-1624D.mdx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 0020e39495..5244d63a91 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -59,8 +59,26 @@ int main() { ```py +from collections import Counter +for _ in range(int(input())): + n, k = map(int, input().split()) + st = input() + cnt = Counter(st) + + pairs_cnt, odd_cnt = 0, 0 + + for c in cnt.values(): + pairs_cnt += c // 2 + odd_cnt += c % 2 + + res = 2 * (pairs_cnt // k) + odd_cnt += 2 * (pairs_cnt % k) + + res += (odd_cnt >= k) + + print(res) ``` From 94b8ec2d56b50e97798cef50096c5f29e9720cf6 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Fri, 8 Nov 2024 20:15:02 +0530 Subject: [PATCH 08/18] update java solution --- solutions/bronze/cf-1624D.mdx | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 5244d63a91..6e21d220e3 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -56,6 +56,46 @@ int main() { ``` + + +```java +import java.io.*; +import java.util.*; + +public class palindromesColoring { + public static void main(String[] args) { + Kattio io = new Kattio(); + int testNum = io.nextInt(); + + for (int t = 0; t < testNum; t++) { + int n = io.nextInt(); + int k = io.nextInt(); + String st = io.next(); + + int cnt[] = new int[26]; + for (int i = 0; i < n; i++) { + cnt[st.charAt(i) - 'a'] += 1; + } + + int pairsCnt = 0, oddCnt = 0; + for (int i = 0; i < 26; i++) { + pairsCnt += cnt[i] / 2; + oddCnt += cnt[i] % 2; + } + + int res = 2 * (pairsCnt / k); + oddCnt += 2 * (pairsCnt % k); + + io.println((oddCnt >= k) ? res + 1 : res); + } + io.close(); + } + + //CodeSnip{Kattio} +} +``` + + ```py @@ -82,5 +122,4 @@ for _ in range(int(input())): ``` - - + \ No newline at end of file From 3faece55d27fa9231c11f035cf8f024242d1a444 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:48:23 +0000 Subject: [PATCH 09/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- solutions/bronze/cf-1624D.mdx | 63 ++++++++++++++++------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 6e21d220e3..9df687c90f 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -32,12 +32,10 @@ int main() { int n, k; std::string st; - std::array cnt {0}; + std::array cnt{0}; std::cin >> n >> k >> st; - for (char x : st) { - cnt[x - 'a']++; - } + for (char x : st) { cnt[x - 'a']++; } int pairs_cnt = 0, odd_cnt = 0; for (int i = 0; i < 26; i++) { @@ -48,11 +46,10 @@ int main() { int res = 2 * (pairs_cnt / k); odd_cnt += 2 * (pairs_cnt % k); res += (odd_cnt >= k); - + cout << res << '\n'; - } + } } - ``` @@ -70,28 +67,26 @@ public class palindromesColoring { for (int t = 0; t < testNum; t++) { int n = io.nextInt(); int k = io.nextInt(); - String st = io.next(); + String st = io.next(); - int cnt[] = new int[26]; - for (int i = 0; i < n; i++) { - cnt[st.charAt(i) - 'a'] += 1; - } + int cnt[] = new int[26]; + for (int i = 0; i < n; i++) { cnt[st.charAt(i) - 'a'] += 1; } - int pairsCnt = 0, oddCnt = 0; - for (int i = 0; i < 26; i++) { - pairsCnt += cnt[i] / 2; - oddCnt += cnt[i] % 2; - } + int pairsCnt = 0, oddCnt = 0; + for (int i = 0; i < 26; i++) { + pairsCnt += cnt[i] / 2; + oddCnt += cnt[i] % 2; + } - int res = 2 * (pairsCnt / k); - oddCnt += 2 * (pairsCnt % k); + int res = 2 * (pairsCnt / k); + oddCnt += 2 * (pairsCnt % k); - io.println((oddCnt >= k) ? res + 1 : res); + io.println((oddCnt >= k) ? res + 1 : res); } - io.close(); + io.close(); } - //CodeSnip{Kattio} + // CodeSnip{Kattio} } ``` @@ -102,24 +97,24 @@ public class palindromesColoring { from collections import Counter for _ in range(int(input())): - n, k = map(int, input().split()) - st = input() + n, k = map(int, input().split()) + st = input() - cnt = Counter(st) + cnt = Counter(st) - pairs_cnt, odd_cnt = 0, 0 + pairs_cnt, odd_cnt = 0, 0 - for c in cnt.values(): - pairs_cnt += c // 2 - odd_cnt += c % 2 + for c in cnt.values(): + pairs_cnt += c // 2 + odd_cnt += c % 2 - res = 2 * (pairs_cnt // k) - odd_cnt += 2 * (pairs_cnt % k) + res = 2 * (pairs_cnt // k) + odd_cnt += 2 * (pairs_cnt % k) - res += (odd_cnt >= k) + res += odd_cnt >= k - print(res) + print(res) ``` - \ No newline at end of file + From cd73f18b6c5dd80a5009323a7a06652f9114a4e7 Mon Sep 17 00:00:00 2001 From: Rameez Parwez <79394137+freakin23@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:09:39 +0530 Subject: [PATCH 10/18] Update cf-1624D.mdx --- solutions/bronze/cf-1624D.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 9df687c90f..b7483d13e3 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -2,7 +2,7 @@ id: cf-1624D source: CF title: Palindromes Coloring -author: Sōsuke +author: Rameez Parwez --- [Official Editorial](https://codeforces.com/blog/entry/98942) From 69982b054c6f9698fccd076fb53cebcd67cffc9c Mon Sep 17 00:00:00 2001 From: freakin23 Date: Sun, 10 Nov 2024 09:04:00 +0530 Subject: [PATCH 11/18] variable change --- solutions/bronze/cf-1624D.mdx | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index b7483d13e3..b1b19ba13a 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -37,15 +37,15 @@ int main() { for (char x : st) { cnt[x - 'a']++; } - int pairs_cnt = 0, odd_cnt = 0; + int num_pairs = 0, num_odd = 0; for (int i = 0; i < 26; i++) { - pairs_cnt += cnt[i] / 2; - odd_cnt += (cnt[i] % 2 == 1); + num_pairs += cnt[i] / 2; + num_odd += (cnt[i] % 2 == 1); } - int res = 2 * (pairs_cnt / k); - odd_cnt += 2 * (pairs_cnt % k); - res += (odd_cnt >= k); + int res = 2 * (num_pairs / k); + num_odd += 2 * (num_pairs % k); + res += (num_odd >= k); cout << res << '\n'; } @@ -72,16 +72,16 @@ public class palindromesColoring { int cnt[] = new int[26]; for (int i = 0; i < n; i++) { cnt[st.charAt(i) - 'a'] += 1; } - int pairsCnt = 0, oddCnt = 0; + int numPairs = 0, numOdd = 0; for (int i = 0; i < 26; i++) { - pairsCnt += cnt[i] / 2; - oddCnt += cnt[i] % 2; + numPairs += cnt[i] / 2; + numOdd += cnt[i] % 2; } - int res = 2 * (pairsCnt / k); - oddCnt += 2 * (pairsCnt % k); + int res = 2 * (numPairs / k); + numOdd += 2 * (numPairs % k); - io.println((oddCnt >= k) ? res + 1 : res); + io.println((numOdd >= k) ? res + 1 : res); } io.close(); } @@ -102,16 +102,16 @@ for _ in range(int(input())): cnt = Counter(st) - pairs_cnt, odd_cnt = 0, 0 + num_pairs, num_odd = 0, 0 for c in cnt.values(): - pairs_cnt += c // 2 - odd_cnt += c % 2 + num_pairs += c // 2 + num_odd += c % 2 - res = 2 * (pairs_cnt // k) - odd_cnt += 2 * (pairs_cnt % k) + res = 2 * (num_pairs // k) + num_odd += 2 * (num_pairs % k) - res += odd_cnt >= k + res += num_odd >= k print(res) ``` From acc9afa8378df8d84762b2f72403d7c57ad42ddc Mon Sep 17 00:00:00 2001 From: freakin23 Date: Sun, 10 Nov 2024 09:05:00 +0530 Subject: [PATCH 12/18] remove std::cout --- solutions/bronze/cf-1624D.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index b1b19ba13a..3cb576cc1b 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -23,8 +23,6 @@ Once we are done adding pairs, we can still add one more character to the middle ```cpp #include -using std::cout; - int main() { int test_num; std::cin >> test_num; From 87336cf9a30de500e0c7b734492be32497d4c158 Mon Sep 17 00:00:00 2001 From: Rameez Parwez <79394137+freakin23@users.noreply.github.com> Date: Sun, 10 Nov 2024 09:48:30 +0530 Subject: [PATCH 13/18] Update solutions/bronze/cf-1624D.mdx Co-authored-by: Justin Ji <68484800+TheGamingMousse@users.noreply.github.com> --- solutions/bronze/cf-1624D.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 3cb576cc1b..f7c195a1a3 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -11,7 +11,7 @@ author: Rameez Parwez We can greedily solve this problem by first forming palindromic pairs from identical characters. We add one pair each of the `k` palindromes we want to build, as long as we have `k` pairs available. -Once we are done adding pairs, we can still add one more character to the middle of each palindrome if there are atleast `k` individual characters remaining. +Once we are done adding pairs, we can still add one more character to the middle of each palindrome if there are at least `k` individual characters remaining. ## Implementation From 3c69d1539b92dcbd46ae55183d2ec6f994fa8aa6 Mon Sep 17 00:00:00 2001 From: Rameez Parwez <79394137+freakin23@users.noreply.github.com> Date: Sun, 10 Nov 2024 12:36:10 +0530 Subject: [PATCH 14/18] Update solutions/bronze/cf-1624D.mdx Co-authored-by: Ryan Chou <81596991+ryanchou-dev@users.noreply.github.com> --- solutions/bronze/cf-1624D.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index f7c195a1a3..27086b88d6 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -27,7 +27,6 @@ int main() { int test_num; std::cin >> test_num; while (test_num--) { - int n, k; std::string st; std::array cnt{0}; From 2dc5687fa92893feb5e54c74905c1add5d951c82 Mon Sep 17 00:00:00 2001 From: Rameez Parwez <79394137+freakin23@users.noreply.github.com> Date: Sun, 10 Nov 2024 12:40:16 +0530 Subject: [PATCH 15/18] Update cf-1624D.mdx --- solutions/bronze/cf-1624D.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 27086b88d6..a8e40541f5 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -5,7 +5,7 @@ title: Palindromes Coloring author: Rameez Parwez --- -[Official Editorial](https://codeforces.com/blog/entry/98942) +[Official Editorial (C++)](https://codeforces.com/blog/entry/98942) ## Explanation @@ -44,7 +44,7 @@ int main() { num_odd += 2 * (num_pairs % k); res += (num_odd >= k); - cout << res << '\n'; + std::cout << res << '\n'; } } ``` From 12fc2720013f57574f756e2dd452ab53cc009bef Mon Sep 17 00:00:00 2001 From: Kevin Sheng <55369003+SansPapyrus683@users.noreply.github.com> Date: Sun, 10 Nov 2024 09:57:21 -0800 Subject: [PATCH 16/18] Update cf-1624D.mdx --- solutions/bronze/cf-1624D.mdx | 66 ++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index a8e40541f5..04fa4342ee 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -10,8 +10,13 @@ author: Rameez Parwez ## Explanation We can greedily solve this problem by first forming palindromic pairs from identical characters. -We add one pair each of the `k` palindromes we want to build, as long as we have `k` pairs available. -Once we are done adding pairs, we can still add one more character to the middle of each palindrome if there are at least `k` individual characters remaining. + +We first add pairs of identical characters to each color, tyring to keep everything as even as possible. +When there's no more pairs, we can still add one more character to the middle of each palindrome. + +Note that when we add lone characters, it may be optimal to break some pairs apart +to even things out a bit more. +This is why we add `2 * (num_pairs % k)` near the end. ## Implementation @@ -21,29 +26,32 @@ Once we are done adding pairs, we can still add one more character to the middle ```cpp -#include +#include +#include +#include int main() { int test_num; std::cin >> test_num; - while (test_num--) { + for (int t = 0; t < test_num; t++) { int n, k; - std::string st; - std::array cnt{0}; - std::cin >> n >> k >> st; + std::string string; + std::cin >> n >> k >> string; - for (char x : st) { cnt[x - 'a']++; } + std::array char_freq{0}; + for (char x : string) { char_freq[x - 'a']++; } - int num_pairs = 0, num_odd = 0; + int num_pairs = 0; + int num_odd = 0; for (int i = 0; i < 26; i++) { - num_pairs += cnt[i] / 2; - num_odd += (cnt[i] % 2 == 1); + num_pairs += char_freq[i] / 2; + num_odd += (char_freq[i] % 2 == 1); } int res = 2 * (num_pairs / k); num_odd += 2 * (num_pairs % k); - res += (num_odd >= k); + res += (num_odd >= k); std::cout << res << '\n'; } } @@ -53,32 +61,35 @@ int main() { ```java -import java.io.*; import java.util.*; +import java.io.*; -public class palindromesColoring { +public class PalindromeColoring { public static void main(String[] args) { Kattio io = new Kattio(); int testNum = io.nextInt(); - for (int t = 0; t < testNum; t++) { int n = io.nextInt(); int k = io.nextInt(); - String st = io.next(); + String string = io.next(); - int cnt[] = new int[26]; - for (int i = 0; i < n; i++) { cnt[st.charAt(i) - 'a'] += 1; } + int charFreq[] = new int[26]; + for (int i = 0; i < n; i++) { + charFreq[string.charAt(i) - 'a'] += 1; + } - int numPairs = 0, numOdd = 0; + int numPairs = 0; + int numOdd = 0; for (int i = 0; i < 26; i++) { - numPairs += cnt[i] / 2; - numOdd += cnt[i] % 2; + numPairs += charFreq[i] / 2; + numOdd += charFreq[i] % 2; } int res = 2 * (numPairs / k); numOdd += 2 * (numPairs % k); - io.println((numOdd >= k) ? res + 1 : res); + res += numOdd >= k ? 1 : 0; + io.println(res); } io.close(); } @@ -95,13 +106,11 @@ from collections import Counter for _ in range(int(input())): n, k = map(int, input().split()) - st = input() - - cnt = Counter(st) + char_freq = Counter(input()) - num_pairs, num_odd = 0, 0 - - for c in cnt.values(): + num_pairs = 0 + num_odd = 0 + for c in char_freq.values(): num_pairs += c // 2 num_odd += c % 2 @@ -109,7 +118,6 @@ for _ in range(int(input())): num_odd += 2 * (num_pairs % k) res += num_odd >= k - print(res) ``` From 67619d9b85fea01ecd480fdcd4888b78171bc6eb Mon Sep 17 00:00:00 2001 From: Kevin Sheng <55369003+SansPapyrus683@users.noreply.github.com> Date: Sun, 10 Nov 2024 09:57:36 -0800 Subject: [PATCH 17/18] Update cf-1624D.mdx --- solutions/bronze/cf-1624D.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index 04fa4342ee..e259731630 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -73,7 +73,7 @@ public class PalindromeColoring { int k = io.nextInt(); String string = io.next(); - int charFreq[] = new int[26]; + int[] charFreq = new int[26]; for (int i = 0; i < n; i++) { charFreq[string.charAt(i) - 'a'] += 1; } From db4dcf40eda4e3dfc4a3d89352bd8f0edaf155fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 17:59:48 +0000 Subject: [PATCH 18/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- solutions/bronze/cf-1624D.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/solutions/bronze/cf-1624D.mdx b/solutions/bronze/cf-1624D.mdx index e259731630..eff7efd51d 100644 --- a/solutions/bronze/cf-1624D.mdx +++ b/solutions/bronze/cf-1624D.mdx @@ -26,9 +26,9 @@ This is why we add `2 * (num_pairs % k)` near the end. ```cpp +#include #include #include -#include int main() { int test_num; @@ -61,8 +61,8 @@ int main() { ```java -import java.util.*; import java.io.*; +import java.util.*; public class PalindromeColoring { public static void main(String[] args) { @@ -74,9 +74,7 @@ public class PalindromeColoring { String string = io.next(); int[] charFreq = new int[26]; - for (int i = 0; i < n; i++) { - charFreq[string.charAt(i) - 'a'] += 1; - } + for (int i = 0; i < n; i++) { charFreq[string.charAt(i) - 'a'] += 1; } int numPairs = 0; int numOdd = 0;