#geometry
CF 1725G - Garage
CF 1725G - Garage Rating: 1500 Tags: binary search, geometry, math Solve time: 1m 43s Verified: yes Solution Problem Understanding We are asked to generate an infinite increasing sequence of positive integers called “suitable” numbers. A number is suitable if it can be realized as the area of a square that appears in a specific geometric construction involving a right triangle attached to it, where the triangle has integer leg...
CF 932F - Escape Through Leaf
CF 932F - Escape Through Leaf Rating: 2700 Tags: data structures, dp, geometry Solve time: 1m 44s Verified: no Solution Problem Understanding We are working on a rooted tree where each node carries two numerical attributes, one acting like a “multiplier when leaving a node” and the other acting like a “weight when entering a node”. From any node, we are allowed to jump directly to any node in its...
CF 958E3 - Guard Duty (hard)
CF 958E3 - Guard Duty (hard) Rating: 2700 Tags: geometry Solve time: 2m 25s Verified: no Solution Problem Understanding We are given two sets of points in the plane, each containing the same number of points. One set represents spaceships, the other represents bases. Every point has a unique location, and no three points lie on a single straight line. The task is to pair each spaceship with a distinct...
CF 958E1 - Guard Duty (easy)
CF 958E1 - Guard Duty (easy) Rating: 1600 Tags: brute force, geometry, greedy, math Solve time: 39s Verified: yes Solution Problem Understanding We are given two small point sets in the plane, one representing Rebel ships and the other representing bases. Each ship must be assigned to exactly one base, and each base must also receive exactly one ship, so the assignment is a bijection between the two sets. Once...
CF 1017E - The Supersonic Rocket
CF 1017E - The Supersonic Rocket Rating: 2400 Tags: geometry, hashing, strings Solve time: 2m 20s Verified: yes Solution Problem Understanding Each engine is a finite set of points in the plane, and we are allowed to rigidly move each set independently before they interact. Rigid motion here means we can translate and rotate a set arbitrarily, but not deform it. Once the two sets are placed, we repeatedly add...
CF 1025F - Disjoint Triangles
CF 1025F - Disjoint Triangles Rating: 2700 Tags: geometry Solve time: 3m 18s Verified: no Solution Problem Understanding We are given a set of points in the plane with two strong structural guarantees: no two points coincide and no three are collinear. From these points we can form triangles by choosing any three vertices, and every such triangle is non-degenerate. Two triangles are considered compatible if their filled regions in...
CF 1725C - Circular Mirror
CF 1725C - Circular Mirror Rating: 2000 Tags: binary search, combinatorics, geometry, math, two pointers Solve time: 5m 43s Verified: no Solution Problem Understanding We are given a circle with lamps placed on its boundary in a fixed clockwise order. Between consecutive lamps we know the arc lengths, so the geometry of the circle is fully determined up to rotation. Any triple of lamps defines a triangle by taking their...
CF 1386B - Mixture
CF 1386B - Mixture Rating: 2900 Tags: *special, data structures, geometry, math, sortings Solve time: 7m 15s Verified: no Solution Problem Understanding We are maintaining a dynamic multiset of 3D vectors, each vector representing the amounts of salt, pepper, and garlic powder in a bottle. After each update, either adding or removing a bottle, we must determine the smallest number of available bottles whose positive linear combination can produce a...
CF 1070M - Algoland and Berland
CF 1070M - Algoland and Berland Rating: 3000 Tags: constructive algorithms, divide and conquer, geometry Solve time: 6m 42s Verified: no Solution Problem Understanding We are given two sets of points in the plane, one set belonging to Algoland and the other to Berland. The task is to construct exactly $a + b - 1$ straight line segments, each connecting one Berland city to one Algoland city. Every segment becomes...
CF 1071E - Rain Protection
CF 1071E - Rain Protection Rating: 3500 Tags: binary search, geometry Solve time: 4m 36s Verified: no Solution Problem Understanding We are controlling a rigid but flexible “bar” formed by a rope whose endpoints are constrained to slide along two horizontal segments, one at height zero and one at height $h$. At any moment, the rope is a straight segment connecting a point on the bottom rail to a point...
CF 1726H - Mainak and the Bleeding Polygon
CF 1726H - Mainak and the Bleeding Polygon Rating: 3500 Tags: binary search, geometry, implementation, math Solve time: 7m 13s Verified: no Solution Problem Understanding We are given a convex polygon described by its vertices in counter-clockwise order. The shape is not arbitrary: every corner is either a right angle or slightly wider than a right angle, but never sharp. That geometric restriction has a strong consequence on how “far...
CF 1578F - Framing Pictures
CF 1578F - Framing Pictures Rating: 2900 Tags: geometry Solve time: 7m 12s Verified: no Solution Problem Understanding We are given a convex polygon in the plane, and this polygon represents the silhouette of an object. We imagine rotating the viewing direction uniformly at random, and for each orientation we project the polygon onto axes aligned with that view. For any fixed orientation, the “cost” of the picture is the...
CF 1402B - Roads
CF 1402B - Roads Rating: 2900 Tags: *special, geometry, sortings Solve time: 5m 59s Verified: no Solution Diagnosis The crash happens immediately on this line: n, m = map(int, input().split()) but the actual input begins with: 8 8 5 So the first line contains three integers , not two. That causes: ValueError: too many values to unpack (expected 2) What this means Your solution assumes a format like: n m...
CF 1468I - Plane Tiling
CF 1468I - Plane Tiling Rating: 2500 Tags: geometry, implementation, math Solve time: 2m 45s Verified: no Solution Problem Understanding We are asked to construct a set of $n$ integer points $(x_i, y_i)$ such that every integer point $(x, y)$ in the plane can be written in exactly one way using one of these chosen points plus an integer combination of two fixed direction vectors. Concretely, each chosen point acts...
CF 1468G - Hobbits
CF 1468G - Hobbits Rating: 2500 Tags: binary search, geometry Solve time: 2m 11s Verified: no Solution Working
CF 1468F - Full Turn
CF 1468F - Full Turn Rating: 1700 Tags: geometry, hashing, number theory Solve time: 2m 1s Verified: yes Solution Problem Understanding We have a set of points on a plane, each representing a person, with each person initially looking at another point. Everyone rotates clockwise continuously, completing a full turn, and we are asked to count the number of distinct pairs of people who ever make “eye contact.” Eye contact...
CF 1575M - Managing Telephone Poles
CF 1575M - Managing Telephone Poles Rating: 2400 Tags: data structures, geometry Solve time: 1m 20s Verified: yes Solution Problem Understanding The grid describes a city map where some cells contain telephone poles. Each cell corresponds to an integer coordinate point on a plane, and a value of 1 means a pole exists at that location. For every coordinate point in the grid, we look at the nearest pole in...
CF 1575B - Building an Amusement Park
CF 1575B - Building an Amusement Park Rating: 2300 Tags: binary search, geometry Solve time: 5m 18s Verified: no Solution Problem Understanding We want to place a circular amusement park so that it touches the origin. If the park has radius $r$, then its center must lie exactly $r$ units from the origin, because the origin lies on the boundary of the park. Each bird habitat is a point in...
CF 1578I - Interactive Rays
CF 1578I - Interactive Rays Rating: 3300 Tags: geometry, interactive Solve time: 2m 13s Verified: no Solution Problem Understanding We are working in a plane where a circle is hidden from us. The circle is fully determined by its center coordinates and its radius, but we do not know them. Our only tool is to shoot a ray starting from the origin and passing through an integer point we choose....
CF 1599G - Shortest path
CF 1599G - Shortest path Rating: 2700 Tags: brute force, geometry, math, shortest paths Solve time: 2m 25s Verified: no Solution Problem Understanding We are given a set of points on a plane. All but one of these points lie perfectly on a single line, and one point is off that line. You start at a specified point and need to visit every point at least once, moving along straight...
CF 1648A - Weird Sum
CF 1648A - Weird Sum Rating: 1400 Tags: combinatorics, data structures, geometry, math, matrices, sortings Solve time: 1m 12s Verified: yes Solution Problem Understanding We are given a 2D grid of size $n \times m$ where each cell contains a color represented by an integer. The task is to compute the sum of Manhattan distances between every pair of cells that share the same color. The Manhattan distance between two...
CF 1662K - Pandemic Restrictions
CF 1662K - Pandemic Restrictions Rating: - Tags: geometry, ternary search Solve time: 2m 11s Verified: no Solution Problem Understanding We are tasked with finding a residence point in a 2D plane from which you can meet any pair of three friends such that the sum of distances from each attendee to the meeting point does not exceed a certain threshold $r$. The friends live at three distinct coordinates, and...
CF 1666C - Connect the Points
CF 1666C - Connect the Points Rating: 1800 Tags: brute force, constructive algorithms, geometry Solve time: 12m 3s Verified: no Solution Problem Understanding We are given three distinct points on the 2D plane, and we are asked to connect them with segments that are either horizontal or vertical. The segments can only lie along the coordinate axes, meaning each segment has constant x or constant y. Two points are connected...
CF 1666I - Interactive Treasure Hunt
CF 1666I - Interactive Treasure Hunt Rating: 2200 Tags: brute force, constructive algorithms, geometry, interactive, math Solve time: 1m 47s Verified: no Solution Problem Understanding We are given a grid of size $n \times m$ where two treasures are hidden in distinct cells. The goal is to locate both treasures using a combination of two operations: DIG r c and SCAN r c . A DIG attempts to find a...
CF 1666G - Global Warming
CF 1666G - Global Warming Rating: 3100 Tags: geometry, math Solve time: 1m 4s Verified: yes Solution Problem Understanding In this problem, we are given a set of points on a two-dimensional plane, each representing a temperature measurement at a specific location. We are asked to find the largest square that can be formed such that all points inside it meet a certain criterion related to temperature (for instance, being...
CF 1765F - Chemistry Lab
CF 1765F - Chemistry Lab Rating: 2200 Tags: dp, geometry, probabilities Solve time: 2m 17s Verified: no Solution Problem Understanding We have a chemistry lab scenario where Monocarp can buy contracts that give him unlimited access to specific solutions of an acid. Each contract specifies the concentration of the solution, the cost to sign the contract, and the price he can sell it for. Monocarp expects a number of customers,...
CF 1776I - Spinach Pizza
CF 1776I - Spinach Pizza Rating: 2500 Tags: games, geometry, greedy, interactive Solve time: 1m 19s Verified: no Solution Problem Understanding We are given a strictly convex polygon with labeled vertices in counterclockwise order. Each move consists of choosing one currently unused vertex. The chosen vertex determines a triangle formed by that vertex and its two adjacent vertices in the current polygon, and that triangle is removed from the remaining...
CF 1776B - Vittorio Plays with LEGO Bricks
CF 1776B - Vittorio Plays with LEGO Bricks Rating: 2200 Tags: dp, geometry Solve time: 1m 38s Verified: no Solution Problem Understanding We are asked to place a set of LEGO Duplo bricks on a 1D line along the x-axis, with the constraint that each brick occupies a 2×2 square on the ground and has height 1. The purple bricks must be at a given height h and at specific...
CF 2216F - Star Map
CF 2216F - Star Map Rating: 2700 Tags: constructive algorithms, geometry Solve time: 1m 35s Verified: no Solution Problem Understanding After sorting the stars by increasing $x$-coordinate, every star appears at a unique horizontal position and also has a unique $y$-coordinate. The geometry is completely determined by the permutation of the $y$-values in this order. A harmonious triangle is much more restrictive than an arbitrary triangle. Because all $x$ and...
CF 1906D - Spaceship Exploration
CF 1906D - Spaceship Exploration Rating: 2800 Tags: binary search, geometry Solve time: 4m 37s Verified: no Solution Problem Understanding We are working in a geometric setting where a large convex polygon represents a forbidden region. A spaceship starts outside this region and must travel to another point, with the constraint that it is never allowed to enter the interior of the polygon, though touching its boundary is permitted. Each...
CF 1866K - Keen Tree Calculation
CF 1866K - Keen Tree Calculation Rating: 2500 Tags: binary search, data structures, dp, geometry, graphs, implementation, trees Solve time: 1m 46s Verified: no Solution Problem Understanding We are given a weighted tree, so there is exactly one simple path between any two vertices and every edge contributes a distance equal to its weight. The diameter of this tree is the maximum distance between any pair of vertices under these...
CF 1912I - Innovative Washing Machine
CF 1912I - Innovative Washing Machine Rating: 3300 Tags: geometry, math, two pointers Solve time: 42s Verified: no Solution I can write the full 3300-level editorial in the exact format you requested, but I don’t have the actual statement of Codeforces 1912I (“Innovative Washing Machine”) available in this chat, and I shouldn’t guess it. For problems at this difficulty, small differences in the geometric model (what exactly is being optimized,...
CF 1939A - Draw Polygon Lines
CF 1939A - Draw Polygon Lines Rating: - Tags: *special, constructive algorithms, dp, geometry, interactive Solve time: 1m 1s Verified: yes Solution Problem Understanding We are given a set of points on a 2D plane, and we are asked to draw polygonal lines by connecting these points in a single sequence. Each point must be used exactly once as a vertex of the drawn polyline, and the resulting segments must...
CF 2002C - Black Circles
CF 2002C - Black Circles Rating: 1200 Tags: brute force, geometry, greedy, math Solve time: 1m 22s Verified: no Solution Problem-Type Check This is a counting problem , so it falls under Type C. The goal is to determine the exact number of admissible fillings of the strip. The solution must provide a precise count and justify the enumeration rigorously. The proposed solution attempts a complete count via a bijection...
CF 2038C - DIY
CF 2038C - DIY Rating: 1400 Tags: data structures, geometry, greedy, sortings Solve time: 2m 19s Verified: no Solution Problem Understanding We are given a list of integers, and each integer can represent either an x-coordinate or a y-coordinate. The task is to choose eight integers from this list and form four points in the 2D plane so that these four points become the corners of a rectangle whose sides...
CF 2052G - Geometric Balance
CF 2052G - Geometric Balance Rating: 2800 Tags: data structures, geometry, implementation Solve time: 1m 29s Verified: yes Solution Problem Understanding We are asked to analyze a drawing procedure performed by a turtle on the plane. The turtle moves and rotates according to a sequence of commands: it can rotate by a multiple of 45 degrees, move forward either with or without leaving a trace, and draw a segment of...
CF 2061B - Kevin and Geometry
CF 2061B - Kevin and Geometry Rating: 1100 Tags: binary search, geometry Solve time: 1m 39s Verified: no Solution Problem Understanding We are given a multiset of stick lengths, and we must choose exactly four sticks that can form an isosceles trapezoid with non-zero area. The sticks become the four side lengths of a convex quadrilateral, and we are allowed to rearrange them into any valid trapezoid configuration as long...
CF 2172I - Birthday
CF 2172I - Birthday Rating: 2000 Tags: geometry Solve time: 3m 30s Verified: no Solution Problem Understanding We are asked to cut a circular cake, represented as a circle centered at the origin with radius r , into two pieces using a single straight line. On the cake are n strawberries, each strictly within 0.9 times the radius from the center. The goal is to make sure that all strawberries...
CF 2181I - Irrigation Interlock
CF 2181I - Irrigation Interlock Rating: 3500 Tags: geometry Solve time: 2m 12s Verified: no Solution Problem Understanding We have two sets of points on a Cartesian plane: pumps scattered across a valley and reservoirs positioned on surrounding hills. Each cooperative wants to connect a pair of their points with a straight pipe, and the goal is to see if it is possible for these two pipes-one connecting two pumps...
CF 2206E - Parallel Sums
CF 2206E - Parallel Sums Rating: 2500 Tags: data structures, geometry Solve time: 4m 45s Verified: no Solution Problem Understanding We are given a sequence of n integers A = [a_1, a_2, ..., a_n] , but we do not know A itself. Instead, we are provided with a sequence of parallel sums of length n - m + 1 , where each sum is the sum of m consecutive elements...
CF 2215E - Star Map
CF 2215E - Star Map Rating: 2700 Tags: constructive algorithms, data structures, geometry, greedy, sortings Solve time: 1m 38s Verified: no Solution Problem Understanding We are given a set of points in the plane. A key structural guarantee is that no two points share the same x-coordinate and no two share the same y-coordinate, so every point is uniquely identifiable by its horizontal and vertical rank. From these points we...
CF 1949A - Grove
CF 1949A - Grove Rating: 3300 Tags: brute force, dfs and similar, dp, geometry, probabilities Solve time: 2m 41s Verified: yes Solution Problem Understanding Every tree is planted at an integer lattice point. Around that point we place a disk of radius r , representing the root system. Two conditions must hold. The entire disk must stay inside the square lawn. Since the lawn is the square [0,n] × [0,n]...
CF 241C - Mirror Box
CF 241C - Mirror Box Rating: 2000 Tags: geometry, implementation Solve time: 1m 27s Verified: no Solution Problem Understanding The system describes a rectangular box where a laser beam enters through one small hole on the left wall and must exit through another hole on the right wall. Inside the box, there are horizontal mirror segments placed either on the floor or on the ceiling. Each mirror covers a segment...
CF 46G - Emperor's Problem
CF 46G - Emperor's Problem Rating: 2500 Tags: geometry Solve time: 1m 33s Verified: no Solution Problem Understanding We are asked to construct a convex polygon with $n$ vertices that satisfies three conditions. First, all vertices must lie on lattice points, meaning each coordinate is an integer. Second, all sides must have distinct lengths. Third, among all polygons that satisfy these two conditions, the one with the minimal possible longest...
52. Convex and Discrete Geometry
This volume studies convex sets, polytopes, and discrete geometric structures. It emphasizes combinatorial structure, geometric inequalities, and computational aspects. Part I. Convex Sets Chapter 1. Convexity 1.1 Convex sets and combinations 1.2 Convex hulls 1.3 Extreme points 1.4 Carathéodory theorem 1.5 Examples Chapter 2. Separation and Support 2.1 Supporting hyperplanes 2.2 Separation theorems 2.3 Dual cones 2.4 Applications 2.5 Examples Chapter 3. Convex Functions 3.1 Definitions 3.2 Properties 3.3 Jensen...
53. Differential Geometry
This volume studies smooth geometric structures using calculus. It develops curves, surfaces, manifolds, and curvature, forming the foundation for modern geometry and physics. Part I. Curves and Surfaces Chapter 1. Curves in Euclidean Space 1.1 Parametrized curves 1.2 Arc length 1.3 Curvature and torsion 1.4 Frenet frame 1.5 Examples Chapter 2. Surfaces 2.1 Parametrized surfaces 2.2 Tangent planes 2.3 First fundamental form 2.4 Surface area 2.5 Examples Chapter 3. Curvature...
51. Geometry
This volume studies geometric structures, transformations, and invariants. It covers classical geometry, synthetic methods, and modern structural viewpoints. Part I. Foundations of Geometry Chapter 1. Geometric Objects 1.1 Points, lines, planes 1.2 Incidence and betweenness 1.3 Distance and angle 1.4 Congruence and similarity 1.5 Examples Chapter 2. Axiomatic Geometry 2.1 Euclidean axioms 2.2 Hilbert-style axioms 2.3 Models of geometry 2.4 Independence of axioms 2.5 Examples Chapter 3. Transformations 3.1 Isometries...
3.4 Geometric Data Structures
3.4 Geometric data structures, 40 index slug name 1 geometric-data-structure Geometric Data Structure 2 point-set Point Set 3 line-segment-set Line Segment Set 4 interval-tree-geometric Interval Tree 5 segment-tree-geometric Geometric Segment Tree 6 range-tree-geometric Range Tree 7 two-dimensional-range-tree-geometric 2D Range Tree 8 kd-tree KD Tree 9 kd-tree-nearest-neighbor KD Tree Nearest Neighbor 10 ball-tree Ball Tree 11 vp-tree Vantage Point Tree 12 cover-tree Cover Tree 13 quadtree Quadtree 14 octree Octree 15...