Detecting Non-Consecutive Duplicate Characters in Task Sequences

The problem requires determining if a sequence of tasks, represented by uppercase letters, violates a specific constraint: once a task is abandoned for a different one, it cannot be resumed. In terms of the string representation, this means no character can reappear after a different character has been encountered.ApproachA straightforward meth ...

Posted on Tue, 20 Oct 2026 16:04:33 +0000 by dannyz

Solving the TENIS Problem from COCI 2018-2019 Finals

The problem determines which players can win a tournament across three courts with distinct rankings. A player defeats another if they have a better (lower) rank in any court. Key Insight Each player is represented by their worst (maximum) rank across all courts, denoted as $m_i$. The set of potential winners forms a contiguous prefix of player ...

Posted on Fri, 16 Oct 2026 16:30:35 +0000 by nick1

Practical String Manipulation Problems in C++

Problem A: String Concatenation Solution #include <iostream> #include <string> int main() { std::string str1, str2; while (std::cin >> str1 >> str2) { str1.append(str2); std::cout << str1 << std::endl; } return 0; } Problem C: Case-Insensitive Substring Deletion Analysis Key ...

Posted on Thu, 15 Oct 2026 16:44:26 +0000 by hcspider

Competitive Programming: Algorithmic Solutions for Mathematical and Tree Problems

Counting Valid Mountain SequencesTo solve the mountain sequence counting problem, we need to determine the number of permutations that satisfy the mountain property. This can be efficiently computed using combinatorial mathematics by recognizing patterns in the sorted sequence.#include <iostream> #include <vector> #include <algor ...

Posted on Wed, 14 Oct 2026 16:38:16 +0000 by jonorr1

Optimized Bitmask Dynamic Programming for Hamiltonian Path and Circuit

The naive dynamic programming approach for Hamiltonian path and circuit problems typically runs in O(n!) time, or O(2ⁿ n³) using standard bitmask DP. We will optimize this bitmask DP framework to achieve O(2ⁿ n) time complexity and O(2ⁿ) space complexity. The baseline bitmask DP uses the state dp[S][u][v], which denotes whether a path exists fr ...

Posted on Tue, 13 Oct 2026 16:16:18 +0000 by cage

Block Partitioning for Summing Numbers with Odd Bit Count

Problem Transformation The core task reduces to computing the sum of all numbers in ([0, N]) whose popcount is odd: $$\sum_{i=0}^{N} [popcount(i) \bmod 2 = 1]$$ where the Iverson bracket ([p]) equals 1 when (p) is true and 0 otherwise. Block Partitioning Strategy When analyzing addition contributions of all numbers in ([0, N]) under binary repr ...

Posted on Sun, 11 Oct 2026 16:57:57 +0000 by Pig

Strategies and Solutions for Codeforces Round 843 Div. 2 Problems

A. Gardener and the Capybaras Given a string composed of characters 'a' and 'b', split it into three non-empty substrings. The goal is to make the middle substring lexicographically either the smallest or the largest among the three. Output any valid split or :( if impossible. Approach: The presence of only 'a' and 'b' is not restrictive. For t ...

Posted on Fri, 09 Oct 2026 16:19:07 +0000 by ben_m_gunn

Solutions to Programming Contest Problems

Problem Solutions Problem 1: Commute Calculation #include <iostream> using namespace std; int main() { int base, bonus1, bonus2; cin >> base >> bonus1 >> bonus2; cout << base + min(bonus1, bonus2) << endl; return 0; } Problem 2: Adoration Count #include <cstdio> #include <algorithm& ...

Posted on Mon, 05 Oct 2026 16:36:31 +0000 by ca87

AtCoder Beginner Contest 059 Problem Solutions

Problem A: Enitial Letter Extraction Given three space-separated lowercase strings, output their initial letters in uppercase. std::string s; std::getline(std::cin, s); for (int i = 0; i < (int)s.size(); i++) { if (i == 0 || s[i - 1] == ' ') std::cout << char(s[i] - 'a' + 'A'); } std::cout << "\n"; Problem B: Large ...

Posted on Fri, 02 Oct 2026 16:54:42 +0000 by joshmpratt

Competitive Programming Solutions: Graph Paths, DP, and Segment Trees

Problem A: Operations with Inversions Greedy solution. Skipped for brevity. Problem B: Optimal Shifts Greedy solution. Skipped for brevity. Problem C: Odd Process Problem Statement: You have n numbers, each with a value a_i. You need to perform k rounds of operations where you can place a number into a bag (each number can only be placed once). ...

Posted on Tue, 29 Sep 2026 16:27:28 +0000 by Pilly