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

Solutions to CodeForces Round #663 (Div. 2) Problems

Given an integer \( n \), construct a permutation of \( 1 \) to \( n \) such that for every interval \([l, r]\), the bitwise OR of elements in the interval is at least the length of the interval. The problem contains multiple test cases. The solution is straightforward: the identity permutation \( (1, 2, \ldots, n) \) satisfies the condition. T ...

Posted on Mon, 11 May 2026 09:26:48 +0000 by telsiin

Weekly Contest 357 Solutions

Problem 2810 - Faulty Keeyboard Simulate the keyboard behavior as described. When encuontering character 'i', reverse the current string. class Solution { public: string finalString(string input) { string result = ""; for(char c : input) { if(c == 'i') { reverse(result.begin(), ...

Posted on Sun, 10 May 2026 02:00:36 +0000 by stone

Understanding Prüfer Sequences for Labeled Trees

Prüfer sequences are defined only for trees with \(n>1\) vertices. For the case \(n=1\), special handling is required. A Prüfer sequence establishes a bijection between labeled rooted trees on \(n\) vertices and sequences of length \(n-2\) drawn from \([1,n]\cap\Z\). This encoding transforms tree structures into arrays, which proves invaluab ...

Posted on Sat, 09 May 2026 05:15:20 +0000 by dude81

Algorithmic Paradigms and Optimizations in Competitive Programming

Probabilistic Path Enumeration in Directed Acyclic Graphs Given a directed acyclic graph (DAG) consisting of $V$ vertices and $E$ edges, each edge $e_k$ possesses an independent activation probability $p_k$. The objective is to compute the expected number of functional paths originating from vertex $0$ and terminating at vertex $V-1$. A path is ...

Posted on Thu, 07 May 2026 22:27:40 +0000 by PDP11

Contest Solutions: Henan Newbie League 2024 Round 5

A – Calendar Game Ignoring the year, the losing positions follow the pattern (month + day) % 2 == 1, except for the two special dates 9/30 and 11/30 which allow the next player to flip the parity. #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; ...

Posted on Thu, 07 May 2026 16:47:06 +0000 by stuart7398