Southwest University for Nationalities 2023 Programming Competition Selection Problems and Solutions

L1-1 Thank You, Karl! This problem requires outputting a specific formatted string. The output contains an emoticon with escaped backslashes. Reference Implementation #include <bits/stdc++.h> using namespace std; int main() { cout << "Thank You Karl!\\\\(>_<)/" << endl; return 0; } L1-2 It's Fantasy ...

Posted on Sat, 01 Aug 2026 16:26:03 +0000 by bender

Solutions for Codeforces Round 899 Division 2 Problems

Problem A: Minimum Non-Conflicting Value Sequence Given a sequence of intgeers, find the smallest positive integer that can be added to make all elements distinct while maintaining increasing order. #include<iostream> #include<vector> using namespace std; int find_min_increment(vector<int>& nums) { int current = 1; ...

Posted on Sat, 01 Aug 2026 16:13:35 +0000 by chaffinator

Binary Tree Algorithm Challenges: Minimum Difference, Modes, and Lowest Common Ancestor

Finding the Minimum Absolute Difference in a BSTGiven the properties of a Binary Search Tree (BST), an in-order traversal processes nodes in ascending order of their values. Consequently, the smallest absolute difference between any two nodes in the tree must exist between two adjacent nodes in this sorted sequence. We can implement a recursive ...

Posted on Thu, 30 Jul 2026 16:47:13 +0000 by MitchEvans

String Hashing Techniques and Applications

Properties of String Hashing Different hash values guarantee different strings. Identical hash values don't guarantee identical strings (though probability is high). Modulus Selection Prime moduli are preferable based on number theory. For example, (ax + b) mod p distributes with interval gcd(a, p). The modulus must prevent overflow in 64-bi ...

Posted on Wed, 29 Jul 2026 16:20:42 +0000 by lalabored

Data Structures Implementations: Leaf Counting, Linked List Insertion, and Unique Like Ranking

Counting Leaf Nodes in a Binary Tree Calculate the number of leaf nodes within a binary tree. A leaf node is defined as a node where both the left and right child pointers are null. #include <stdio.h> #include <stdlib.h> typedef char ElemType; typedef struct BiTNode { ElemType data; struct BiTNode *lchild, *rchild; } BiTNod ...

Posted on Tue, 28 Jul 2026 16:53:11 +0000 by glence

Computing All Integer Factors in Ascending Order with Rust

A straightforward Rust implementation for finding all factors of a number is shown below. This approach iterates up to the square root of the input value. fn compute_factors_simple(num: u64) -> Vec<u64> { let sqrt_val = (num as f64).sqrt().floor() as u64; let mut factors = Vec::new(); for divisor in 1..=sqrt_val { i ...

Posted on Tue, 28 Jul 2026 16:25:21 +0000 by pazzy

Solutions for Codeforces Round 855 (Div. 3)

Problem A: Is It a Cat? Givan a string and its length, output "YES" if the string satisfies the following conditions; otherwise, output "NO": The string consists of exactly four segments. Each segment contains only one letter (case-insensitive), in the exact sequence: 'm', 'e', 'o', 'w'. There are t test cases. Approach Th ...

Posted on Mon, 27 Jul 2026 17:02:01 +0000 by mindrage00

Decoding Java's Seeded Random: How 'Hello World' Emerges from Chaos

The Mystery of Deterministic Randomness Consider this peculiar Java code that outputs "hello world" despite using seemingly random operations: public class RandomStringGenerator { public static void main(String[] args) { System.out.println(createRandomString(-229985452) + " " + createRandomString(-147909649)); } public st ...

Posted on Mon, 27 Jul 2026 16:54:46 +0000 by unknown

Implementing a Sorted Singly Linked List in C

A singly linked list is built using a structure containing data and a pointer to the next node. This dynamic data strcuture supports efficient insertion, deletion, and traversal operations. Below is a concise implementation that maintains elements in ascending order during insertion: #include <stdio.h> #include <stdlib.h> typedef s ...

Posted on Sun, 26 Jul 2026 17:18:45 +0000 by dlgilbert

Memory Allocation and String Manipulation in C: Arrays vs Pointers

In C programming, handling strings requires a clear understanding of how memory is allocated. Strings can be managed using either character arrays or character pointers, each behaving differently regarding memory size and data manipulation. 1. String Manipulation Using Character Arrays When using a character array, memory is statically allocate ...

Posted on Sat, 25 Jul 2026 17:09:06 +0000 by ridckie_rich