Solutions to AGC016 Programming Contest Problems
A - Shrinking
Given a string s, determine the minimum number of operasions required to make all characters identical. Each operation reduces the string length by one by selecting characters from adjacent positions.
#include <bits/stdc++.h>
using namespace std;
int main() {
string input;
cin >> input;
int length = input. ...
Posted on Fri, 19 Jun 2026 17:54:39 +0000 by decodv
Problem Solving Approaches for AtCoder Beginner Contest 045
Problem A: Trapezoid Area
Given the upper base $a$, lower base $b$, and height $h$ of a trapezoid, the area is calculated using the formula:
$$\text{Area} = \frac{(a + b) \times h}{2}$$
Problem B: Card Game for Three
Three players, A, B, and C, each start with a string of cards. Starting with player A, they draw cards in a sequence. If a player ...
Posted on Tue, 09 Jun 2026 17:50:46 +0000 by Ben5on
Solving AtCoder Beginner Contest 367 Problems with C++
A - Shout Everyday
This problem involves checking if a specific hour falls within a given time range spanning across midnight. We handle the wrap-around by adjusting the end time.
#include <cstdio>
int main() {
int target, start, end;
scanf("%d %d %d", &target, &start, &end);
if (end <= start) en ...
Posted on Tue, 09 Jun 2026 16:32:03 +0000 by $var
AtCoder ABC 069 Solutions
Problem A - 4
Question
With (n) horizontal lines and (m) vertical lines drawn on a plane, how many axis-aligned rectangles are formed that contain no interior lines?
Solution
Consider each dimension independent.
Along any straight line, (n) distinct points partition the line into (n - 1) segments. These segments serve as the edges of our rectan ...
Posted on Fri, 22 May 2026 20:05:22 +0000 by suresh1
AtCoder Beginner Contest 002 Solutions
Problem A: Maximum Value
Given two positive integers as input, output the larger value.
Solution
Simply compare the two values and output the maximum.
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << max(a, b) << endl;
return 0;
}
Problem B: Remove Vowel ...
Posted on Wed, 20 May 2026 21:00:00 +0000 by HostingTrade
Solutions for AtCoder Beginner Contest 319
Legendary Players
A direct mapping from player handles to their respective ratings is required. A hash map provides an efficient and clean way to resolve this without writing multiple conditional statements.
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
unordered_map< ...
Posted on Tue, 19 May 2026 22:20:14 +0000 by drawmack
Four Tasks from a Beginner Contest: Permutation Duel, Sub-grid Matching, Hamiltonian Walks, and Optimal Chemical Blending
Task A – Permutation Duel
A cyclic permutation maps
[1\to2\to3\to\dots\to13\to1]
Two players choose indices (x,y\in[1,13]). Compare the images (p(x)) and (p(y)); output the winner or "Draw".
int main() {
int x, y; std::cin >> x >> y;
int px = (x == 13 ? 1 : x + 1);
int py = (y == 13 ? 1 : y + 1);
if (px == ...
Posted on Fri, 15 May 2026 19:42:06 +0000 by NathanLedet
AtCoder Regular Contest 104 Problem Solutions
Problem A: Plus Minus
Given the sum and difference of two numbers, we can easily retrieve the original values. The first number is the average of the sum and difference, while the second is half of the difference subtracted from the sum.
s, d = map(int, input().split())
print((s + d) // 2, (s - d) // 2)
Problem B: DNA Sequence
A substring is c ...
Posted on Fri, 15 May 2026 00:15:36 +0000 by ganich
Three-Point Search and Substring Analysis for AtCoder ABC 043
Problem A
Compute the sum \(\sum_{i=1}^{n} i = \binom{n+1}{2}\).
Problem B
Statement:
Given a string, process it from left to right. Whenever a character B is encountered, it removes itself and the character immediately to its right (if any). Output the final remaining string.
Solution:
Use a stack-like approach: iterate over the input and push ...
Posted on Wed, 13 May 2026 10:36:54 +0000 by jswinkelman
Preliminary solutions for AtCoder Beginner Contest 064
Problem A: Check multiples of 4
Given three digits a, b, c (most significant first), form the three-digit number n = 100*a + 10*b + c. Determine whether n is divisible by 4.
int a, b, c; cin >> a >> b >> c;
int n = a * 100 + b * 10 + c;
cout << (n % 4 == 0 ? "YES" : "NO") << "\n";
Pro ...
Posted on Mon, 11 May 2026 07:02:20 +0000 by lostsoul111455