Solutions to ARC143 Problems: Three Integers, Counting Grids, and Piles of Pebbles

T1 Three Integers Problem Statement Given three integers A, B, and C, there are two operations: Operation 1: Choose two numbers and decrement each by 1. Operation 2: Choose all three numbers and decrement each by 1. The goal is to reduce all three numbers to 0. If impossible, output -1. Solution Approach A key insight is that any operation sh ...

Posted on Sun, 20 Sep 2026 16:12:21 +0000 by evlive

AtCoder Beginner Contest 012 - Problem Solutions

A - Swapping Two Integers Read two integers, swap their values, and output them on separate lines. B - Time Conversion Given N seconds where 0 ≤ N < 86400, convert it to 24-hour time format hh:mm:ss. The conversion formula using modular arithmetic: [N \equiv a_0 \times 3600 + a_1 \times 60 + a_2 \times 1 \pmod{86400}] Calculate hours, minute ...

Posted on Sat, 19 Sep 2026 16:13:54 +0000 by Ryokotsusai

AGC022F Checkers: A Dynamic Programming Approach on Multi-way Trees

We examine the problem of merging \(n\) initial unit vectors \(\mathbf{e}_1,\ldots,\mathbf{e}_n\) via operations that combine two vectors \(\mathbf{u},\mathbf{v}\) into either \(2\mathbf{u} - \mathbf{v}\) or \(2\mathbf{v} - \mathbf{u}\), depending on which one "wins". Each final vector’s \(i\)-th component is of the form \((-1)^{c_i}2 ...

Posted on Tue, 15 Sep 2026 16:36:04 +0000 by cneale

Solutions to AtCoder Beginner Contest 055 Problems

Problem A Each meal costs 800 yen. For every 15 meals purchased, a refund of 200 yen is issued. Given $ x $, the total number of meals consumed, compute the net expenditure. The formula is: $$ 800x - \left\lfloor \frac{x}{15} \right\rfloor \cdot 200 $$ Problem B After $ N $ workouts, where initial strength is 1 and each $ i $-th workout multipl ...

Posted on Fri, 11 Sep 2026 16:45:57 +0000 by YOUAREtehSCENE

ABC 046 Solutions: Counting, Coloring, Votes and RPS

A – Distinct Count Input three integers. Output how many different values appear. #include <bits/stdc++.h> using namespace std; int main() { set<int> bag; for (int i = 0; i < 3; ++i) { int x; cin >> x; bag.insert(x); } cout << bag.size() << '\n'; } B – Coloring a Line of Balls G ...

Posted on Sat, 05 Sep 2026 16:05:44 +0000 by adrian_quah

: "Four Algorithmic Challenges: Month Cycles, String Formatting, Constrained Reductions, and Random Walk Probabilities"

Month Transition Calculation Problem Statement Given an integer current_month representing a month (1 through 12), compute the subsequent month in the annual cycle. Solution Approach Months follow a cyclic pattern with base 12. Converting to zero-based indexing simplifies modular arithmetic. Implementation def calculate_next_month(m: int) -> ...

Posted on Sun, 30 Aug 2026 16:10:57 +0000 by klpang

AtCoder Beginner Contest 049 Solutions

Problem A Determine if a given character is one of the vowels a, e, i, o, u. A simple approach uses a hash map to store the vowels. For efficiency, characters are hashed by subtracting 'a', and a custom hash table implementation handles lookups. template <class T, int P = 314159> struct hashmap { u64 id[P]; T val[P]; int rec[P ...

Posted on Mon, 24 Aug 2026 16:13:46 +0000 by noobh

Algorithmic Solutions to AtCoder Beginner Contest 057

Problem A: 24-Hour Time Calculation Given the current time $A$ and a duration $B$ in hours, the task is to determine the start time of an event using a 24-hour clock format. Since the clock cycles every 24 hours, the solution involves a simple modular arithmetic operation. The resulting time is calculated as $(A + B) \pmod{24}$. #include < ...

Posted on Mon, 10 Aug 2026 16:46:33 +0000 by Jimmy_uk

Solving AtCoder Beginner Contest 356 Problems

Problem A: Array Segment Reversal Given an array of integers from 1 to n, reverse a specified segment between indices l and r. #include <iostream> #include <algorithm> using namespace std; int main() { int n, l, r; cin >> n >> l >> r; int arr[n+1]; for(int i=1; i<=n; i++) arr[i] = i; reverse ...

Posted on Sat, 08 Aug 2026 17:00:05 +0000 by Buchead

Advanced Re-rooting Dynamic Programming Walkthrough

Re-rooting DP is a tree-DP variant that looks intimidating at first, yet becomes very mechenical once the pattern is recognized. The following problems illustrate the key techniques. Problem 1 – USACO 2012 FEB "Nearby Cows" Task: for every node i compute the sum of weights of all nodes whose distance to i is at most K. Constraints: n ...

Posted on Wed, 29 Jul 2026 16:38:52 +0000 by daf_cr