#matrices
CF 1252K - Addition Robot
CF 1252K - Addition Robot Rating: 2100 Tags: data structures, math, matrices Solve time: 1m 52s Verified: no Solution Problem Understanding The robot stores a binary instruction string over the alphabet {A, B}. When we process this string with an initial pair of values (A, B) , each character acts like a small transformation step. If the current character is A , the second value is added into the first,...
CF 1023E - Down or Right
CF 1023E - Down or Right Rating: 2100 Tags: constructive algorithms, interactive, matrices Solve time: 2m 14s Verified: no Solution Problem Understanding We are given an unknown $n \times n$ grid where each cell is either open or blocked. Movement is only allowed from a cell to its right neighbor or its bottom neighbor, and only if the destination cell is open. The goal is to determine any valid path...
CF 1025E - Colored Cubes
CF 1025E - Colored Cubes Rating: 2700 Tags: constructive algorithms, implementation, matrices Solve time: 5m 51s Verified: yes Solution Problem Understanding We are given an $n \times n$ grid and $m$ identical-sized cubes, each having a unique color. Each cube starts on a distinct cell, and each also has a target cell where it must eventually be placed. Some cubes may already start on their destination, but otherwise every cube...
CF 1184D2 - Parallel Universes (Hard)
CF 1184D2 - Parallel Universes (Hard) Rating: 3100 Tags: math, matrices Solve time: 2m 28s Verified: yes Solution Problem Understanding We are simulating a probabilistic system that evolves a one-dimensional structure of length l , where a distinguished position called the Doctor’s current universe is fixed inside this structure. At every step, the system randomly either grows by inserting a new universe or shrinks by cutting a connection and discarding...
CF 1402C - Star Trek
CF 1402C - Star Trek Rating: 2600 Tags: *special, combinatorics, dfs and similar, dp, games, graphs, matrices, trees Solve time: 1m 26s Verified: yes Solution Problem Understanding We are given a tree of $N$ planets. Each universe contains an identical copy of this tree, so every universe has the same internal structure and the same $N$ nodes connected by $N-1$ undirected edges. There are $D+1$ universes indexed from $0$ to...
CF 1599E - Two Arrays
CF 1599E - Two Arrays Rating: 3200 Tags: data structures, matrices Solve time: 2m 32s Verified: no Solution Problem Understanding We are given two arrays, A1 and A2 , each with N integers, and a sequence of Q queries that modify these arrays or ask for a sum over a Fibonacci transformation of their element-wise sums. The modification queries either clamp values to a minimum or maximum, or add a...
CF 1609E - William The Oblivious
CF 1609E - William The Oblivious Rating: 2400 Tags: bitmasks, data structures, dp, matrices Solve time: 1m 55s Verified: no Solution Problem Understanding We are working with a mutable string consisting only of the characters a , b , and c . After each update, we must answer a structural question about the string: how many positions must be changed so that the string no longer contains abc as a...
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 1662C - European Trip
CF 1662C - European Trip Rating: - Tags: dp, graphs, math, matrices Solve time: 5m 17s Verified: no Solution Problem Understanding We are asked to count special trips on a graph of cities. Each city is a node, and each road is an undirected edge connecting two cities. A trip of length k is a sequence of k+1 cities such that each consecutive pair is connected by a road. A...
CF 1970E3 - Trails (Hard)
CF 1970E3 - Trails (Hard) Rating: 2200 Tags: dp, matrices Solve time: 2m 16s Verified: no Solution Problem Understanding We are asked to count the number of possible sequences of trails Harry can take over n days starting from cabin 1. Each day consists of two moves: first from his current cabin to the lake, then from the lake to any cabin. Each cabin has a given number of short...
CF 1970E2 - Trails (Medium)
CF 1970E2 - Trails (Medium) Rating: 2000 Tags: dp, matrices Solve time: 1m 39s Verified: yes Solution Problem Understanding The problem describes a scenario where Harry Potter moves between a set of cabins and a central lake along trails. Each cabin has a number of short and long trails connecting it to the lake. Each day, Harry makes exactly two moves: first from his current cabin to the lake, then...
CF 2181K - Knit the Grid
CF 2181K - Knit the Grid Rating: 3500 Tags: 2-sat, constructive algorithms, graphs, matrices Solve time: 2m 47s Verified: no Solution Problem Understanding The canvas is a rectangular grid of cells, but the real structure lives on its grid graph: vertices are grid intersection points and edges connect adjacent intersections horizontally or vertically. Initially, some collection of simple cycles is drawn along these edges. The cycles are vertex-disjoint, and every...
15. Linear and Multilinear Algebra; Matrix Theory
This volume develops vector spaces, linear maps, matrices, and multilinear structures. It serves as a core toolkit for nearly all areas of mathematics, physics, and computation. Part I. Vector Spaces Chapter 1. Vector Spaces 1.1 Definitions and examples 1.2 Subspaces 1.3 Linear combinations 1.4 Span and generation 1.5 Linear independence Chapter 2. Bases and Dimension 2.1 Bases 2.2 Existence of bases 2.3 Dimension 2.4 Coordinate representations 2.5 Change of basis...
Tiling
Array Tiling Array tiling divides a multidimensional array into small rectangular regions called tiles. Each tile is processed before moving to the next tile. You use it when matrix or grid operations touch nearby elements repeatedly and cache locality affects performance. Problem Given a matrix $A$ with $r$ rows and $c$ columns, process all elements in tiles of size: $$ t_r \times t_c $$ where $t_r$ is the tile height...