Solutions for 2020 ICPC Asia Shenyang Regional Contest Problems
Problem D: Journey to Un'Goro
For small sequence lengths (n ≤ 20), iterate through all possible binary strings of length n. For each string, compute the prefix sum of red characters ('r' represented as 1, 'b' as 0). Count the number of subarrays where the sum of reds is odd. Track the maximum count and collect all configurations achieving it.
F ...
Posted on Wed, 19 Aug 2026 16:39:07 +0000 by andreas
ABC311 Contest Solutions
A - First ABC
Solution
We can track the first appearence of each character using boolean flags. By iterating through the string, we can determine the earliest position where all three required characters have been encountered.
#include <iostream>
#include <string>
using namespace std;
int main() {
int length;
string input;
...
Posted on Tue, 18 Aug 2026 16:36:57 +0000 by sysop
Codeforces Round 166 Div. 2: A Walkthrough
This document details the solutions for problems from Codeforces Educational Round 166 (Rated for Div. 2).
A. Verify Password
The problem requires validating a password string based on specific criteria. The approach involves iterating through the password and checking adjacent character pairs against the rules. A password is valid if it adhere ...
Posted on Sun, 16 Aug 2026 16:50:06 +0000 by mainewoods
Comprehensive Problem Solutions from Paken Camp Contests
2023 Edition
Day 1
G. Constructing an MST with Product Weights (Easy)
We are given a sequence (a) (with (|a_i| \le 10^6)), and we must build an undirected graph on (n) vertices ((n \le 2\cdot 10^5)) where the weight of edge ((i,j)) equals (a_i a_j). The goal is to compute the weight of the minimum spanning tree.
First, sort (a); this has no eff ...
Posted on Fri, 14 Aug 2026 16:32:06 +0000 by Chinese
Solutions for CodeForces Round 656 Division 3
A - Three Pairwise Maximums
Given three pairwise maximum values, determine if they can be derived from three positive integers. The solutoin involves sorting the input values and verifying consistency conditions.
#include <iostream>
#include <algorithm>
using namespace std;
void solve() {
int nums[3];
cin >> nums[0] & ...
Posted on Fri, 07 Aug 2026 17:03:21 +0000 by lewisstevens1
Python Essentials for Competitive Programming and Algorithm Contests
1. Efficient Input Handling
In competitive programming, reading data efficiently is crucial. Python provides several ways to handle single and multiple lines of input.
# Reading a single string
user_data = input()
# Reading and converting to an integer
base_value = int(input())
# Reading multiple space-separated integers into variables
start, ...
Posted on Thu, 06 Aug 2026 16:30:36 +0000 by jpraj
Solving Linear Range Checking and Interval Removal Problems in C++
Problem 1: Threshold-based Item Counting
The first challenge involves determining how many items in a fixed-size collection (10 elements) satisfy a specific condition. The logic requires comparing each item's value against a threshold value. This threshold is derived from a base input value added to a constant offset of 30 units.
The solution i ...
Posted on Wed, 05 Aug 2026 17:06:09 +0000 by bandit8
Competitive Programming Solutions: SMU Winter 2025 Round 1
Problem A: Level Progression Validation
The task requires verifying the consistency of game level statistics over multiple sessions. We are given a sequence of records, each containing the total number of games played and the total levels cleared. For the records to be valid, three conditions must be met:
Both total games played and total leve ...
Posted on Wed, 05 Aug 2026 16:43:39 +0000 by Timewell
Essential Algorithm Implementations in C++
Number Theory
Fast Exponentiation
Computes base raised to the power of exp modulo mod efficiently using binary decomposition.
long long fast_power(long long base, long long exp, long long mod) {
long long result = 1;
base %= mod;
while (exp > 0) {
if (exp & 1) result = (result * base) % mod;
base = (base * bas ...
Posted on Wed, 05 Aug 2026 16:13:30 +0000 by cherubrock74
Competitive Programming Solutions: Niuke Summer Multi-School Training Camp 2024
Given an integer x, construct a y < x such that gcd(x, y) = x ⊕ y (bitwise XOR).
The solution is to take y = x - lowestSetBit(x). If x is a power of 2, then no solution exists.
#include<iostream>
#include<cmath>
using namespace std;
using ll = long long;
void solve() {
ll x;
cin >> x;
ll lowest_bit = x & ...
Posted on Tue, 04 Aug 2026 16:19:06 +0000 by VLE79E