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