Account Merging with Union-Find Data Structure

Problem Description Given a list of accounts where each account is represented as a list of strings, the first element being a name and the remaining elements being email addresses associated with that account. The task is to merge these accounts based on shared email addresses. If two accounts have at least one email in common, they belong to ...

Posted on Wed, 05 Aug 2026 16:32:12 +0000 by arya202

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

Essential Algorithms for Programming Competition Preparation

This collection presents fundamental algorithms and their applications to simple problems, primari sourced from the Lanqiao Cup competition. The problems are relatively straightforward, focusing more on algorithm templates and basic approaches. For better algorithm retention, the implementations are concise, frequently utilizing built-in C++ fu ...

Posted on Wed, 29 Jul 2026 16:32:20 +0000 by ThaboTheWuff

Algorithmic Solutions: Interval Partitioning, Graph Matching, and Trie-Based Set Operations

Problem A: Large-Scale Simulation A pure simulation problem centered on game theory mechanics. The implementation involves directly modeling the described rules and state transitions. Problem B: Maximum Total Range for k-Partition Define the weight of a subarray as its range (maximum element minus minimum element). For each k from 1 to n, compu ...

Posted on Thu, 16 Jul 2026 16:19:13 +0000 by killfall

AtCoder ABC 447 Contest Solutions

Problem D - Take ABC 2 An efficient approach involves processing the string from the end to identify and count valid "ABC" sequences. #include <vector> #include <string> #include <iostream> using namespace std; void processString() { string input; cin >> input; vector<int> posA, posB, posC; ...

Posted on Sat, 11 Jul 2026 16:17:57 +0000 by Sa177ir

Optimizing Prisoner Allocation Using Union-Find and Binary Search

The problem involves distributing N prisoners into two separate prisons based on M pairs of conflicts. Each conflict pair is defined by two prisoner IDs and a conflict weight. The objective is to arrange the prisoners such that the maximum conflict weight among any two prisoners sharing the same prison is minimized. We need to determine this mi ...

Posted on Fri, 03 Jul 2026 16:29:09 +0000 by PHPSpirit

Essential Techniques for Competitive Programming: Bit Manipulation, Discretization, and DP Fundamentals

Core Problem-Solving Strategies Bitwise Operations Bitwise operators provide efficient alternatives to arithmetic operations: Operator Description Behavior & AND Result is 1 only if both bits are 1 | OR Result is 0 only if both bits are 0 ^ XOR Result is 1 when bits differ ~ NOT Flips all bits << Left Shift Shifts bits ...

Posted on Wed, 20 May 2026 20:06:51 +0000 by Nuser

Minimum Spanning Tree Algorithmic Practice Problems

Problem A: Road Construction Description There are n initially isolated cities. In each round, every city connects to its nearest neighbor. If a cycle formss during a round, the shortest edge in that cycle is removed. Once cities are connected, they form a "union" and act as a single entity in subsequent rounds. The process continues ...

Posted on Fri, 15 May 2026 17:29:52 +0000 by peter.t

Merging Account Lists via Disjoint Set Union

Problem Definition Given a list of accounts accounts, where each accounts[i] is a list of strings. The first string accounts[i][0] is the user's name. The remaining strings are email addresses belonging to that account. The objective is to merge accounts that belong to the same user. Two accounts belong to the same person if they share at least ...

Posted on Mon, 11 May 2026 13:18:36 +0000 by rishiraj

Disjoint Set Union (DSU): Tree-Based Dynamic Disjoint Sets Management

Sets and Common Operations A set is an unordered, duplicate-free collection of elements, mathematically denoted as (S = {x, y, z, \dots}). For example, two sets tracking event participants could be: (Photography = {\text{Liam}, \text{Mia}, \text{Noah}, \text{Emma}, \text{Ethan}} | \text{Event photography team volunteers}) (Videography = {\tex ...

Posted on Sun, 10 May 2026 15:19:33 +0000 by cybersurfur