brain

tamnd's digital brain — notes, problems, research

43815 notes

Kvant Math Problem 166

Let $A_1$ and $A_2$ be the sets of participants of the two trips, and let $B_i \subset A_i$ be the boys in the $i$-th trip.

kvantmathematicsolympiad
Kvant Math Problem 157

Let

kvantmathematicsolympiad
CF 325E - The Red Button

We are asked to find a sequence of node disarmaments for a circular system of size n where node 0 is special. Node 0 must appear twice: first at the start and last at the end. Every other node must appear exactly once.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardsugraphsgreedy
CF 325C - Monsters and Diamonds

Each monster type has one or more split rules. Applying a rule consumes one monster of that type and produces two things: First, some number of diamonds. Second, a multiset of new monsters.

codeforcescompetitive-programmingdfs-and-similargraphsshortest-paths
CF 323C - Two permutations

Each value from 1 to n appears exactly once in both permutations. For a value v, let: - posP[v] be its position in the first permutation. - posQ[v] be its position in the second permutation.

codeforcescompetitive-programmingdata-structures
CF 323B - Tournament-graph

We are asked to construct a tournament graph of n vertices with a specific connectivity property. A tournament graph is a directed graph where every pair of distinct vertices has exactly one directed edge between them.

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 323A - Black-and-White Cube

We are asked to color every small cube inside a larger cube of size k × k × k using exactly two colors, black and white, with a specific local neighbor condition. Each small cube must have exactly two neighboring cubes of the same color.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithms
CF 322A - Ciel and Dancing

The task describes a dancing room where every performance involves exactly one boy and exactly one girl. The participants start with no prior experience, and during each dance at least one of the two people must be dancing for the first time.

codeforcescompetitive-programminggreedy
CF 322B - Ciel and Flowers

We are given three independent supplies of items, each representing flowers of a fixed color. From these supplies we can form bouquets in two fundamentally different ways.

codeforcescompetitive-programmingcombinatoricsmath
CF 321B - Ciel and Duel

We are given two sets of cards, one belonging to Jiro and one belonging to Ciel. Jiro’s cards come in two types, Attack and Defense, each with a strength value. Ciel’s cards are simpler: every one of her cards is an Attack card with a given strength.

codeforcescompetitive-programmingdpflowsgreedy
CF 321C - Ciel the Commander

We are given a tree with up to 100,000 nodes, and we must assign each node a letter from 'A' to 'Z'. These letters represent ranks, where 'A' is the strongest and 'Z' is the weakest.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardivide-and-conquergreedytrees
CF 321E - Ciel and Gondolas

We are given a line of people from position 1 to position n, and we must split this line into exactly k contiguous groups. Each group corresponds to a gondola ride and contains consecutive people in the queue.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdp
CF 321D - Ciel and Flipboard

We have a square board of size n by n, where n is always an odd number. Each cell contains an integer, which may be positive or negative.

codeforcescompetitive-programmingdpgreedymath
CF 321A - Ciel and Robot

We are asked to determine whether a robot moving on a 2D plane can reach a target point (a, b). The robot starts at the origin (0, 0) and follows a sequence of moves encoded in a string.

codeforcescompetitive-programmingbinary-searchimplementationmath
CF 320A - Magic Numbers

We are given a single integer written in decimal form, and we must decide whether it can be constructed by repeatedly placing one of three fixed building blocks next to each other: 1, 14, and 144.

codeforcescompetitive-programmingbrute-forcegreedy
CF 320B - Ping-Pong (Easy Version)

We are maintaining a growing collection of open intervals on the number line. Each time a new interval is added, it becomes a node in an implicit directed graph.

codeforcescompetitive-programmingdfs-and-similargraphs
CF 319A - Malek Dance Club

We are given a binary string that we interpret as an integer, and from it we construct a fixed pairing between two ordered sets of size $2^n$.

codeforcescompetitive-programmingcombinatoricsmath
CF 319C - Kalila and Dimna in the Logging Industry

We are given a sequence of trees with strictly increasing heights. Each tree can be cut down one unit at a time using a chainsaw. The chainsaw requires recharging after each cut, and the recharge cost depends on which trees have already been fully cut.

codeforcescompetitive-programmingdpgeometry
CF 319E - Ping-Pong

We are asked to maintain a dynamic set of intervals and answer reachability queries between them. Each interval is represented by two integers $(x, y)$ where $x < y$. Intervals are added one by one, and each new interval is guaranteed to be strictly longer than all previous ones.

codeforcescompetitive-programmingdata-structures
CF 319D - Have You Ever Heard About the Word?

We are given a single string and we repeatedly compress certain patterns inside it. The only pattern that matters is a substring that consists of two identical halves placed back to back, so a segment of the form X + X, where X is any non-empty string.

codeforcescompetitive-programminggreedyhashingstring-suffix-structuresstrings
CF 319B - Psychos in a Line

We are given a permutation of the numbers from 1 to n arranged in a line. Each position represents a “psycho” with a unique strength value, and the line evolves in discrete rounds. In one round, every psycho compares himself with the person immediately to his right.

codeforcescompetitive-programmingdata-structuresimplementation
CF 317B - Ants

We are asked to simulate the dispersal of ants on a two-dimensional integer grid. Initially, all n ants are placed at the origin (0, 0).

codeforcescompetitive-programmingbrute-forceimplementation
CF 317C - Balance

We are given a set of n vessels, each capable of holding up to v liters of water. Some vessels are connected by tubes that allow water to be transferred in integer amounts.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphstrees
CF 317E - Princess and Her Shadow

We have a two-dimensional integer grid representing a forest. Each cell can be empty or contain a tree. The Princess starts at a cell (vx, vy) and her Shadow starts at (sx, sy).

codeforcescompetitive-programmingconstructive-algorithmsshortest-paths
CF 317D - Game with Powers

We are given a set of integers from 1 to n. Two players alternate turns, and each move consists of selecting a number that has not been eliminated yet.

codeforcescompetitive-programmingdpgames
CF 317A - Perfect Pair

We are given two integers, $x$ and $y$, and a target threshold $m$. A pair is considered m-perfect if at least one of the two numbers is greater than or equal to $m$.

codeforcescompetitive-programmingbrute-force
CF 316A1 - Special Task

The problem asks us to count how many numeric codes match a hint string that can contain fixed digits, wildcards, and letters representing digit equality constraints. Each character in the hint string represents a position in the safe code. A question mark ?

codeforcescompetitive-programminggreedy
CF 316G3 - Good Substrings

We are given a main string $s$ and several constraints, each constraint consists of a pattern string $p$ and a numeric interval $[l, r]$.

codeforcescompetitive-programmingstring-suffix-structures
CF 316G1 - Good Substrings

We are asked to count the number of distinct substrings of a string s that satisfy a set of occurrence-based rules.

codeforcescompetitive-programminghashingstrings
CF 316F3 - Suns and Rays

The task is to analyze a binary image where 0 represents the background and 1 represents a sun or its rays. Each sun consists of a central ellipse (which may be rotated) and several rays extending outward as line segments from the ellipse’s boundary.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similarimplementation
CF 316F2 - Suns and Rays

The input is a pixel grid made of two values, where one value represents empty background and the other represents ink belonging to drawn objects.

codeforcescompetitive-programming
CF 316E3 - Summer Homework

We are maintaining an array that changes over time through point updates and range updates, while also answering range queries.

codeforcescompetitive-programmingdata-structuresmath
CF 316E1 - Summer Homework

We are given an array of integers, and we need to process a sequence of operations that modify the array or query it in a special way. There are three types of operations: direct assignment of a value to an element, range sums weighted by Fibonacci numbers, and range increments.

codeforcescompetitive-programmingbrute-forcedata-structures
CF 316D3 - PE Lesson

We are given a line of students, each initially holding a distinct labeled ball from 1 to n. The only operation allowed is choosing two different students and swapping the balls they currently hold.

codeforcescompetitive-programmingdpmath
CF 316D2 - PE Lesson

We are given a line of students, each initially holding a distinct labeled ball. The only operation allowed is to pick two students and swap the balls they currently hold.

codeforcescompetitive-programmingdp
CF 316B2 - EKG

We are given a queue of n beavers, each numbered from 1 to n. Each beaver either knows who should be immediately in front of them, represented as a[i] (the number of that beaver), or does not know, represented as 0.

codeforcescompetitive-programmingdfs-and-similardp
CF 316B1 - EKG

We are given a structure of people standing in a queue, but the queue is not fully known. Each person either clearly knows who stands immediately in front of them or does not know that information at all.

codeforcescompetitive-programmingbrute-forcedfs-and-similar
CF 315B - Sereja and Array

We have an array of integers and a sequence of operations. One operation changes a single position to a new value. Another operation adds the same number to every element in the array. The third operation asks for the current value at a specific position.

codeforcescompetitive-programmingimplementation
CF 315A - Sereja and Bottles

Each bottle has two properties. The value a[i] is the bottle's own brand. The value b[i] is the brand of bottles that this bottle can open. A bottle can be opened if there exists some other bottle whose opening capability matches its brand.

codeforcescompetitive-programmingbrute-force
CF 314C - Sereja and Subsequences

We are given an array of positive integers. Consider every distinct non-empty non-decreasing subsequence of the array. For each such subsequence $y = (y1,dots,yk)$, we count all positive integer sequences $x = (x1,dots,xk)$ satisfying $$xi le yi$$ for every position.

codeforcescompetitive-programmingdata-structuresdp
CF 314A - Sereja and Contest

The participants are listed in final rank order. Participant i has rating a[i]. For a table of size m, if a participant currently occupies position p, his rating change is $$d = sum{text{participants before him}} aj (posj-1) - ai (p-1)(m-p)$$ In the original statement this…

codeforcescompetitive-programmingimplementation
CF 314E - Sereja and Squares

The geometric description hides a much simpler combinatorial structure. Take a pair of points $(l,0)$ and $(r,0)$, with $l<r$. The left endpoint is marked by a lowercase letter and the right endpoint by the corresponding uppercase letter.

codeforcescompetitive-programmingdp
CF 314D - Sereja and Straight Lines

We are asked to place two perpendicular lines on a plane so that one of them makes a 45-degree angle with the x-axis, and the maximum Manhattan distance from a set of given points to either line is minimized. The input provides the coordinates of n points on the plane.

codeforcescompetitive-programmingbinary-searchdata-structuresgeometrysortingstwo-pointers
CF 314B - Sereja and Periods

We are given two strings, a and c, and two integers, b and d. The string a is repeated b times to form a long string w, and the string c is repeated p times to form another string q.

codeforcescompetitive-programmingbinary-searchdfs-and-similarstrings
CF 313A - Ilya and Bank Account

The problem centers on Ilya’s bank account balance, which is a signed integer. Positive values indicate savings, and negative values indicate debt.

codeforcescompetitive-programmingimplementationnumber-theory
CF 313C - Ilya and Matrix

We are asked to construct a $2 times n times 2 times n$ square matrix from a given list of $4n$ integers such that a recursively defined "beauty" measure is maximized.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationsortings
CF 313E - Ilya and Two Numbers

Codeforces 313E: Ilya and Two Numbers

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdsugreedy
CF 313D - Ilya and Roads

We have a row of holes on a road, numbered from 1 to $n$. Each hole can be repaired by hiring one of $m$ companies.

codeforcescompetitive-programmingdp
CF 313B - Ilya and Queries

We are given a string composed solely of the characters "." and "". The task is to answer multiple queries efficiently. Each query asks, within a substring from position l to r, how many times a character is immediately followed by an identical character.

codeforcescompetitive-programmingdpimplementation
CF 312B - Archer

Two archers shoot at a target alternately. SmallR shoots first and hits with probability $a/b$ on each shot. Zanoes hits with probability $c/d$ on each shot. As soon as someone lands the first hit of the match, the game ends and that player wins.

codeforcescompetitive-programmingmathprobabilities
CF 312A - Whose sentence is it?

We are given a small chat log with up to 10 sentences. Each sentence is a string of letters, underscores, commas, periods, and spaces. Two people, Freda and Rainbow, are involved. According to prior experience, Freda always ends her sentences with the substring "lala.

codeforcescompetitive-programmingimplementationstrings
CF 295A - Greg and Array

We are given an array of integers, and we need to perform multiple operations on ranges of this array. Each operation specifies a contiguous segment of the array and a value to add to every element in that segment.

codeforcescompetitive-programmingdata-structuresimplementation
CF 277D - Google Code Jam

Vasya is participating in a programming round with several problems, each split into a Small and a Large input. Completing the Small input of a problem gives him a guaranteed number of points in a certain amount of time.

codeforcescompetitive-programmingdpprobabilities
CF 277B - Set of Points

We are asked to construct a set of n points on the 2D plane such that the largest convex polygon that can be formed from these points has exactly m vertices. No three points may lie on a straight line.

codeforcescompetitive-programmingconstructive-algorithmsgeometry
CF 277E - Binary Tree on Plane

We are given a set of points in the plane, each with distinct coordinates, and we are asked to connect them into a directed rooted binary tree with the additional geometric constraint that every edge must go downward in the plane.

codeforcescompetitive-programmingflowstrees
CF 277C - Game

Every interior grid line of the paper is divided into unit segments by the lattice points. A cut along a grid line marks all unit segments touched by the knife as already cut. The crucial observation is that the geometry of the paper never changes.

codeforcescompetitive-programminggamesimplementation
CF 311E - Biologist

We are asked to maximize the net money SmallR can gain from an experiment on dogs, where she can change each dog’s sex at a given cost.

codeforcescompetitive-programmingflows
CF 311D - Interval Cubing

We are given an array of integers and a sequence of queries. Each query is either asking for the sum of a subarray or instructing us to cube every element in a subarray. The output consists of the answers to the sum queries, computed modulo 95542721.

codeforcescompetitive-programmingdata-structuresmath
CF 311A - The Closest Pair

We are given a set of points in a 2D plane. The original geometric task would normally be to compute the smallest Euclidean distance among all pairs of points.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 309A - Morning run

We are asked to compute the expected number of collisions between runners on a circular track. Each runner starts at a distinct position along a track of length l and chooses to run either clockwise or counter-clockwise with equal probability.

codeforcescompetitive-programmingbinary-searchmathtwo-pointers
CF 309C - Memory for Arrays

We are given a memory layout split into several contiguous free segments, which we can think of as independent blocks of space. Each block has a fixed length, and we also have a collection of arrays we may want to place into this memory.

codeforcescompetitive-programmingbinary-searchbitmasksgreedy
CF 309E - Sheep

We are given a collection of segments on a very large number line. Each sheep corresponds to one segment, and two sheep become “connected” if their segments overlap in at least one point. After this preprocessing, we must arrange all sheep in a single linear order.

codeforcescompetitive-programmingbinary-searchgreedy
CF 309D - Tennis Rackets

We are asked to count the number of obtuse triangles that can be drawn inside an equilateral triangular tennis racket frame. The racket’s three sides each have n equally spaced holes.

codeforcescompetitive-programmingbrute-forcegeometry
CF 309B - Context Advertising

We are given a sequence of words in fixed order, and we want to select a consecutive block of them, starting at some position and ending later, such that this block can be printed on a rectangular banner.

codeforcescompetitive-programmingdptwo-pointers
CF 300B - Coach

We are asked to divide n students into teams of exactly three. Some students explicitly request to be on the same team with certain other students. These requests are mutual, so if student 2 wants to team with student 5, then student 5 also wants student 2.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphs
CF 300C - Beautiful Numbers

We are given two fixed digits, and we are allowed to build length-n numbers using only those two digits. Any such number is considered “valid” in the first sense, because every position is constrained to a two-element alphabet instead of the full decimal set.

codeforcescompetitive-programmingbrute-forcecombinatorics
CF 300E - Empire Strikes Back

We are asked to determine the minimum positive integer $n$ such that the factorial $n!$ divided by a set of numbers $[a1, a2, dots, ak]$ produces an integer. In other words, the Empire has a strike strength $n!$, and each Republican strike is represented by $ai$.

codeforcescompetitive-programmingbinary-searchmathnumber-theory
CF 300D - Painting Square

We are given a square table of size n × n, initially all white, with a black border around the edges. Vasily the bear can perform exactly k painting moves.

codeforcescompetitive-programmingdpfft
CF 300A - Array

We are given an array of distinct integers and asked to split it into three non-empty sets. The first set must have a product less than zero, the second set a product greater than zero, and the third set a product equal to zero.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
CF 297C - Splitting the Uniqueness

We are given an array of distinct non-negative integers s of length n. The goal is to split each element s[i] into a pair of non-negative integers a[i] and b[i] such that a[i] + b[i] = s[i]. We want both a and b to be almost unique.

codeforcescompetitive-programmingconstructive-algorithms
CF 297B - Fish Weight

The task is to determine whether it is possible for Alice's total fish weight to strictly exceed Bob's, given only the types of fish each caught. Fish types are numbered from 1 to k in non-decreasing weight order, but the exact weights are unknown.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 297E - Mystic Carvings

We are given a circle with $2n$ labeled points arranged in order around the boundary. Each point is used exactly once as an endpoint of a chord, so the chords form a perfect matching on these $2n$ positions. Each chord connects two boundary points.

codeforcescompetitive-programmingdata-structures
CF 297D - Color the Carpet

We are asked to color an h × w grid using at most k colors, while satisfying as many adjacency constraints as possible. Each square in the grid must be assigned an integer color between 1 and k.

codeforcescompetitive-programmingconstructive-algorithms
CF 297A - Parity Game

We are given two binary strings, and we can transform the first string using two operations that behave like a sliding window with a dynamically growing tail. The first operation appends a single bit determined by the parity of the current number of ones in the string.

codeforcescompetitive-programmingconstructive-algorithms
CF 296B - Yaroslav and Two Strings

We are given two digit strings of equal length, but some positions may contain unknown characters represented by ?. Each ? can independently be replaced by any digit from 0 to 9, and choices in different positions do not interact.

codeforcescompetitive-programmingcombinatoricsdp
CF 296A - Yaroslav and Permutations

Yaroslav has a sequence of integers, and he wants to rearrange them so that no two consecutive elements are equal. The only allowed operation is swapping two neighboring elements, and he wants to know if it is possible to reach a configuration satisfying this condition.

codeforcescompetitive-programminggreedymath
CF 295C - Greg and Friends

Every person weighs either 50 kg or 100 kg. A boat starts on the left bank and can carry any non-empty group whose total weight does not exceed the boat limit. Somebody inside the boat must steer it, so every crossing contains at least one passenger.

codeforcescompetitive-programmingcombinatoricsdpgraphsshortest-paths
CF 295E - Yaroslav and Points

We have a set of points on the number line. Each point has an identity, so when an update says "move point p by d", only that specific point changes position. There are two operations.

codeforcescompetitive-programmingdata-structures
CF 295D - Greg and Caves

We are asked to count the number of ways to paint a rectangle of size n by m with black and white cells so that it forms a "cave." In practical terms, each row can either be all white or have exactly two black cells.

codeforcescompetitive-programmingcombinatoricsdp
CF 295B - Greg and Graph

We are given a complete weighted directed graph with n vertices, represented as an adjacency matrix. Each entry a[i][j] is the weight of the edge from vertex i to vertex j. The graph is complete, so every pair of distinct vertices has an edge in both directions.

codeforcescompetitive-programmingdpgraphsshortest-paths
CF 294A - Shaass and Oskols

We are given a sequence of horizontal wires, each with some birds sitting on it. Wires are numbered from top to bottom, and on each wire, the birds are lined up from left to right. Shaass shoots birds one by one.

codeforcescompetitive-programmingimplementationmath
CF 294C - Shaass and Lights

We have a row of n lights. Some positions are already on, and all other positions are off. A move consists of choosing an off light that has at least one adjacent light already on, then switching it on. We continue until every light becomes on.

codeforcescompetitive-programmingcombinatoricsnumber-theory
CF 294E - Shaass the Great

We are given a tree with n cities connected by n-1 roads, where each road has a positive length. Every pair of cities has a unique path connecting them.

codeforcescompetitive-programmingdptrees
CF 294D - Shaass and Painter Robot

We have a kitchen floor of size n×m tiles, all initially white. A robot stands on a border tile at coordinates (xs, ys) and faces one of the four diagonal directions. Each time the robot moves to a tile, it paints it black. If it hits a wall, it reflects like a billiard ball.

codeforcescompetitive-programmingbrute-forceimplementationnumber-theory
CF 294B - Shaass and Bookshelf

We are given a collection of books, each with a thickness of either 1 or 2 units and a width representing how many pages it occupies horizontally. Shaass wants to arrange all books on a single bookshelf.

codeforcescompetitive-programmingdpgreedy
CF 293B - Distinct Paths

Codeforces 293B: Distinct Paths

codeforcescompetitive-programmingbrute-forcecombinatorics
CF 293A - Weird Game

We are asked to analyze a turn-based game between two players, Yaroslav and Andrey, who each have a binary string of length 2·n. They alternately pick positions from the combined index set {1, 2, …, 2·n}.

codeforcescompetitive-programminggamesgreedy
CF 293E - Close Vertices

We are given a tree with n vertices, where each edge carries a non-negative weight. For any two vertices, the distance between them can be measured in two ways: the number of edges along the path connecting them, and the sum of edge weights along that path.

codeforcescompetitive-programmingdata-structuresdivide-and-conquertrees
CF 293D - Ksusha and Square

We are given a convex polygon whose vertices have integer coordinates. Consider every lattice point, meaning every point with integer coordinates, that lies inside the polygon or on its boundary.

codeforcescompetitive-programminggeometrymathprobabilitiestwo-pointers
CF 293C - Cube Problem

The three original cubes had side lengths $a$, $b$, and $c$. Their total number of unit cubes was $$a^3+b^3+c^3.$$ Vitaly wanted to build one larger cube whose side length was $a+b+c$, which would require $$(a+b+c)^3$$ unit cubes.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 292B - Network Topology

We are given a connected undirected graph representing a computer network. The task is not to analyze arbitrary graph structure, but to determine whether the graph exactly matches one of three specific topologies. A bus topology is simply a path.

codeforcescompetitive-programminggraphsimplementation
CF 292A - SMSC

We are given a sequence of tasks that arrive at a corporation's SMS center. Each task consists of a time ti when it arrives and a number ci of text messages to send. The SMS center can send at most one message per second, and messages are queued in the order they arrive.

codeforcescompetitive-programmingimplementation
CF 292E - Copying Data

We are asked to maintain two arrays of integers, a and b, each of length n. The first array a is static: its values never change.

codeforcescompetitive-programmingdata-structures
CF 292D - Connected Components

We have an undirected graph representing a computer network. The vertices are computers and the edges are cables. The cables are numbered from 1 to m in the order they appear in the input.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpdsu
CF 292C - Beautiful IP Addresses

We are given a set of decimal digits. We must find every IP address consisting of four integers between 0 and 255 such that, after writing the four numbers next to each other without dots, the resulting string is a palindrome. The digit restriction is strict.

codeforcescompetitive-programmingbrute-force
CF 291A - Spyke Talks

We are given a list of secretaries and, for each, either a Spyke session number or 0 if the secretary is idle. Each positive session number represents an ongoing call between exactly two people.

codeforcescompetitive-programming*specialimplementationsortings
CF 291C - Network Mask

Each IP address is really a 32-bit integer written in dotted decimal form. A subnet mask is also a 32-bit value, but it must have a very specific shape: some number of leading 1 bits followed by some number of trailing 0 bits.

codeforcescompetitive-programming*specialbitmasksbrute-forceimplementation
CF 291E - Tree-String Problem

We are given a rooted tree with $n$ vertices, where each edge is labeled with a non-empty string. The root of the tree is vertex 1. Each non-root vertex $v$ has a parent $pv$ and a string $sv$ on the edge from $pv$ to $v$.

codeforcescompetitive-programming*specialdfs-and-similarhashingstrings
CF 291D - Parallel Programming

We are asked to simulate a parallel memory-writing process. There are n processors and n memory cells. Each processor can only write to its corresponding cell, but all processors can read any cell. Initially, all cells except the last one contain 1, and the last cell contains 0.

codeforcescompetitive-programming*specialgreedy
CF 291B - Command Line Arguments

We are given a single command-line string written in the fictional Pindows operating system. A command line consists of lexemes, which are the tokens passed to a program. There are two ways a lexeme can appear. A normal lexeme is a maximal sequence of non-space characters.

codeforcescompetitive-programming*specialimplementationstrings