Counting and Maximizing Product of Similar Substrings using Suffix Array and Disjoint Set Union
The annual "Phantom Pavilion Summer Wine Tasting Conference" features two events: tasting and a fun challenge. The tasting event awards the title of "Chief Taster," and the challenge event awards "Chief Hunter." Many wine tasters participate.
At the conference dinner, bartender Rainbow prepares n glasses of cocktai ...
Posted on Mon, 20 Jul 2026 17:12:27 +0000 by Seraph
Solutions to a Set of Algorithmic Challenges from an ACGO Ranking Contest
Six problems drawn from a competitive programming rating competition are analysed below. Every solution is accompanied by both C++ and Python implementations. Keep in mind that Python code may run slower and care should be taken with complexity constants.
Problem 1 – Output a Digit Different from the Product
Given two integers a and b, print an ...
Posted on Thu, 16 Jul 2026 16:13:10 +0000 by machiavelli1079
Solving Luogu High-Precision Arithmetic Problems with Java BigInteger
Java's standard library includes the BigInteger class, which simplifies handling arbitrary-precision inteegrs, eliminating the need to manually implement high-precision logic for basic arithmetic tasks.
P1303 A*B Problem
import java.math.BigInteger;
import java.util.Scanner;
public class MultiplyDemo {
public static void main(String[] args ...
Posted on Wed, 15 Jul 2026 17:30:08 +0000 by endlyss
Counting Identification Cards That Clear All Gates Using Interval Intersection
We have N identification cards, numbered from 1 to N, and M gates. The i-th gate can be passed by any card whose number lies in the inclusive range [L_i, R_i]. Find the number of cards that can pass through all M gates individually.
Input is given on standard input in the following format:
N M
L1 R1
L2 R2
...
LM RM
Print a single integer: the ...
Posted on Sun, 12 Jul 2026 17:26:46 +0000 by coldkill
Dynamic Programming Problems
It is clear that S represents the initial magic value, k is the number of selected items, and x is given in the problem.
Noting that x is large but k and n are small, we can define a state that tracks the i-th item, the number of selected items j, and the sum modulo k as l. The goal is to maximize the initial magic value, as higher values reduc ...
Posted on Thu, 09 Jul 2026 17:14:51 +0000 by Virii
Competitive Programming Solutions: Algorithmic Strategies
Problem 1: Frequency Balance Optimization
Brute force enumeration approach.
We iterate through all possible height levels from 1 to n, calculating the maximum achievable sum by counting elements that can meet the height constraint at each level.
View solution code``` #include #include #include
using namespace std;
void solve() { int size; cin & ...
Posted on Wed, 08 Jul 2026 16:42:36 +0000 by mottwsc
Solutions for 2024 RoboCom CAIP Programming Skills Provincial Competition
RC-u1 Heat Wave
Problem Summary: Given daily maximum temperatures and the day of the week for the first day, count how many days have temperatures ≥ 35°C. Days falling on weekends (Saturday and Sunday) should be counted separately.
Solution: Iterate through the temperature data while tracking the current weekday. For each temperature ≥ 35, incr ...
Posted on Tue, 07 Jul 2026 17:58:05 +0000 by [UW] Jake
Solving the Watchcow Patrol Problem with Eulerian Circuit
Problem Statement
Farmer John has N farms (2 ≤ N ≤ 10^4) connected by M roads (1 ≤ M ≤ 5×10^4). Multiple roads between the same pair of farms are allowed.
Bassie starts patrolling from farm 1. Every road must be traversed exactly once in each direction, and the path must end back at farm 1.
Output any valid sequence of farms that satisfies the ...
Posted on Tue, 07 Jul 2026 16:41:18 +0000 by tha_mink
XCPC Nanjing Regional Problem Solutions: B, G, and H
Problem B: What, More Kangaroos?
Operations 1 and 2 nullify eachother, as do operations 3 and 4. The problem reduces to applying positive integer operations on two buttons only, yielding four enumeration cases.
With operations 1 and 3 chosen, let operation 1 execute x times and operation 3 execute y times (x, y > 0). The goal is maximizing i ...
Posted on Mon, 06 Jul 2026 17:09:43 +0000 by jgetner
SMU Spring 2023 Trial Contest Round 9
A. Incorrect Subtraction
Simulate the process of subtracting 1 from the last digit of a number for k times. If the last digit is 0, remove it instead.
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e3 + 10, mod = 1e9 +7;
typedef pair<int,int> PII;
int n,m,t,k;
vector<int& ...
Posted on Fri, 03 Jul 2026 16:28:51 +0000 by mella