#hashing
CF 1553B - Reverse String
CF 1553B - Reverse String Rating: 1300 Tags: brute force, dp, hashing, implementation, strings Solve time: 1m 34s Verified: no Solution Problem Understanding We are given a string that represents a line of characters. A chip starts on some chosen position in this string. After placing it, we repeatedly move it and each time we record the character at the chip’s current position. The movement has a strict structure: the...
CF 963D - Frequency of String Rating: 2500 Tags: hashing, string suffix structures, strings Model: gpt-5-3-mini Solve time: 1m 49s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a33a36d-603c-83ec-9659-5838d7876b75 Solution Problem Understanding We are given a fixed text string and then many independent pattern queries. Each query gives a pattern string and a required frequency. For each query we need to look at all substrings of the main string that contain the pattern...
CF 958A2 - Death Stars (medium)
CF 958A2 - Death Stars (medium) Rating: 2000 Tags: hashing, strings Solve time: 1m 31s Verified: yes Solution Problem Understanding We are given two rectangular grids of characters. The first grid has size $N \times M$, while the second grid has size $M \times N$. We are asked to find a way to align these two grids so that a square submatrix of size $M \times M$ taken from the...
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 1553G - Common Divisor Graph
CF 1553G - Common Divisor Graph Rating: 2700 Tags: brute force, constructive algorithms, dsu, graphs, hashing, math, number theory Solve time: 3m 40s Verified: yes Solution Problem Understanding We are given a fixed set of nodes, each labeled by a distinct integer. Two nodes are connected if their labels share any prime factor. This means the graph is determined entirely by the prime factorizations of the given numbers. For each...
CF 1320D - Reachable Strings
CF 1320D - Reachable Strings Rating: 2500 Tags: data structures, hashing, strings Solve time: 4m 29s Verified: no Solution Problem Understanding We are given a fixed binary string, and we repeatedly consider two kinds of local transformations on any contiguous segment of length three: swapping 011 into 110 , or the reverse swap 110 into 011 . Each operation only touches three consecutive characters and preserves the total number of...
CF 1252F - Regular Forestation
CF 1252F - Regular Forestation Rating: 2400 Tags: hashing, trees Solve time: 4m 24s Verified: no Solution Problem Understanding We are given a tree with up to 4000 nodes, and we are allowed to pick a single node and remove it. Removing a node splits the tree into several connected components, each of which is itself a tree. The number of components equals the degree of the removed node. The...
CF 1214D - Treasure Island
CF 1214D - Treasure Island Rating: 1900 Tags: dfs and similar, dp, flows, hashing Solve time: 3m 29s Verified: yes Solution Problem Understanding We are given an $n \times m$ grid that represents a map. Each cell is either blocked or free. We start at the top-left cell $(1,1)$ and want to reach the bottom-right cell $(n,m)$. Movement is highly restricted: from any cell we can only go either one...
CF 1773B - BinCoin
CF 1773B - BinCoin Rating: 2200 Tags: binary search, divide and conquer, hashing, implementation, probabilities, trees Solve time: 2m 27s Verified: no Solution Problem Understanding We are given a rooted binary tree with $n$ employees. Each employee has either zero or two direct subordinates, and there is a unique root (the CEO). The company runs a procedure that produces a full ordering of all employees, and this procedure is executed...
CF 1654F - Minimal String Xoration
CF 1654F - Minimal String Xoration Rating: 2800 Tags: bitmasks, data structures, divide and conquer, greedy, hashing, sortings, strings Solve time: 2m 42s Verified: yes Solution Problem Understanding We are given a string whose length is a power of two, indexed from 0 to $2^n - 1$. The key operation allowed is a global reindexing of the string using bitwise XOR with a fixed mask $j$. In other words, we...
CF 1277D - Let's Play the Words?
CF 1277D - Let's Play the Words? Rating: 1900 Tags: data structures, hashing, implementation, math Solve time: 2m 3s Verified: no Solution Problem Understanding We are given a collection of binary strings, and we are allowed to optionally reverse some of them. After doing so, we want to arrange all strings in a single sequence such that every adjacent pair is compatible: the last character of a word must match...
CF 1322C - Instant Noodles
CF 1322C - Instant Noodles Rating: 2300 Tags: graphs, hashing, math, number theory Solve time: 2m 42s Verified: no Solution Yes, the inequality $\nu(n) \le 2^{l(n) - \lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $\lambda(n)$ be the length of a shortest chain consisting only of doubling steps. Each nondoubling step can at most double the number of ones in the...
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 1500A - Going Home
CF 1500A - Going Home Rating: 1800 Tags: brute force, hashing, implementation, math Solve time: 19m 39s Verified: no Solution Problem Understanding We are given an array of integers representing a gift from a friend to Nastya. She wants to find four distinct indices in the array such that the sum of the elements at the first two indices equals the sum of the elements at the other two indices....
CF 1599F - Mars
CF 1599F - Mars Rating: 2700 Tags: hashing Solve time: 2m 23s Verified: no Solution Problem Understanding We are given a list of city positions on a circular Martian colony where cities are numbered modulo $10^9+7$. Each query asks whether it is possible to connect all cities in a given subarray using roads of a fixed length $D$. Connecting with a road of length $D$ means that, if you take...
CF 1906B - Button Pressing
CF 1906B - Button Pressing Rating: 2600 Tags: bitmasks, constructive algorithms, hashing Solve time: 1m 46s Verified: no Solution Problem Understanding We have a line of lamps, each either on or off, and a line of buttons, one per lamp. Each button affects only the lamps immediately adjacent to it: pressing button $i$ toggles lamps $i-1$ and $i+1$, if they exist. The twist is that a button can only be...
CF 2002G - Lattice Optimizing
CF 2002G - Lattice Optimizing Rating: 3400 Tags: bitmasks, brute force, hashing, meet-in-the-middle Solve time: 39s Verified: no Solution Exploration The problem asks only for existence or nonexistence in three classes. For part (1), it suffices to exhibit a tetrahedron that tiles space by congruent copies. For part (2), we must decide whether a congruent tiling by equifacial tetrahedra exists. An equifacial tetrahedron is a disphenoid, that is, a tetrahedron...
CF 2002D2 - DFS Checker (Hard Version)
CF 2002D2 - DFS Checker (Hard Version) Rating: 2300 Tags: binary search, data structures, dfs and similar, graphs, hashing, trees Solve time: 2m 23s Verified: no Solution Problem Understanding We are given a rooted tree where vertex 1 is the root. Alongside the tree, we maintain a permutation stored in an array indexed by positions, and we repeatedly swap two positions in this array. After each swap, we must decide...
CF 2002D1 - DFS Checker (Easy Version)
CF 2002D1 - DFS Checker (Easy Version) Rating: 1900 Tags: brute force, data structures, dfs and similar, graphs, hashing, trees Solve time: 1m 30s Verified: yes Solution Problem Understanding We are given a perfect binary tree whose vertices are numbered in heap order. Vertex 1 is the root, and for every vertex i > 1 , its parent is i // 2 . A permutation p of all vertices is...
CF 2034E - Permutations Harmony
CF 2034E - Permutations Harmony Rating: 2200 Tags: combinatorics, constructive algorithms, greedy, hashing, math Solve time: 2m 25s Verified: yes Solution Problem Understanding We need to construct $k$ distinct permutations of length $n$ such that if we look at any position $i$, the sum of the values appearing at that position across all $k$ permutations is the same for every position. If we denote the permutations by $p_1,p_2,\dots,p_k$, then for...
CF 2038I - Polyathlon
CF 2038I - Polyathlon Rating: 2500 Tags: binary search, data structures, hashing, string suffix structures, strings Solve time: 1m 33s Verified: yes Solution Problem Understanding We are asked to simulate a multi-sport elimination competition with a twist: each participant has a binary skill vector indicating which sports they are proficient in. When a sport is played, the participants who lack skill in that sport are eliminated, provided that at least...
CF 2041I - Auto Complete
CF 2041I - Auto Complete Rating: 2300 Tags: binary search, data structures, hashing, implementation, sortings, strings, trees Solve time: 2m 10s Verified: yes Solution Problem Understanding We are asked to simulate an advanced text editor that supports four operations: adding patterns for auto-complete, deleting patterns, appending text to the current editor content, and deleting characters from the end of the current content. After each operation, the editor should suggest the...
CF 2172H - Shuffling Cards with Problem Solver 68!
CF 2172H - Shuffling Cards with Problem Solver 68! Rating: 2500 Tags: hashing, string suffix structures, strings Solve time: 2m 18s Verified: yes Solution Problem Understanding We are given a deck of $2^k$ cards represented as a string of lowercase letters. The deck can be rotated by moving the first $m$ cards to the end. After this optional rotation, the deck is riffle-shuffled $t$ times. A perfect riffle shuffle splits...