messages listlengths 2 2 | conversation_id int64 0 5k |
|---|---|
[
{
"content": "Polycarp has $n$ different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: \"0001\", \"11\", \"0\" and \"0011100\".\n\nPolycarp wants to offer his set of $n$ binary words to play a game \"words\". In this game, players name words ... | 0 |
[
{
"content": "Mikhail walks on a Cartesian plane. He starts at the point $(0, 0)$, and in one move he can go to any of eight adjacent points. For example, if Mikhail is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(1, 1)$; $(0, 1)$; $(-1, 1)$; $(-1, 0)$... | 1 |
[
{
"content": "You are given three sequences: $a_1, a_2, \\ldots, a_n$; $b_1, b_2, \\ldots, b_n$; $c_1, c_2, \\ldots, c_n$.\n\nFor each $i$, $a_i \\neq b_i$, $a_i \\neq c_i$, $b_i \\neq c_i$.\n\nFind a sequence $p_1, p_2, \\ldots, p_n$, that satisfy the following conditions:\n\n\n\n $p_i \\in \\{a_i, b_i, c_i\\}... | 2 |
[
{
"content": "You have $n$ barrels lined up in a row, numbered from left to right from one. Initially, the $i$-th barrel contains $a_i$ liters of water.\n\nYou can pour water from one barrel to another. In one act of pouring, you can choose two different barrels $x$ and $y$ (the $x$-th barrel shouldn't be empty... | 3 |
[
{
"content": "You are given a permutation $p=[p_1, p_2, \\ldots, p_n]$ of integers from $1$ to $n$. Let's call the number $m$ ($1 \\le m \\le n$) beautiful, if there exists two indices $l, r$ ($1 \\le l \\le r \\le n$), such that the numbers $[p_l, p_{l+1}, \\ldots, p_r]$ is a permutation of numbers $1, 2, \\ld... | 4 |
[
{
"content": "The sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.\n\nDreamoon has two permutations $p_1$ and $p_2$ of non-zero lengths $l_1$ and $l_2$.\n\nNow Dreamoon concatenates these two perm... | 5 |
[
{
"content": "Arthur owns a ski resort on a mountain. There are $n$ landing spots on the mountain numbered from $1$ to $n$ from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go towards the foot of the mountain, so there are no directed cycles formed by ... | 6 |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nNow elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.\n\nThere are $n$ voters, and two ways to convince each of them to vote for you. The first way to convince the $i$-th ... | 7 |
[
{
"content": "You like playing chess tournaments online.\n\nIn your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you ge... | 8 |
[
{
"content": "Alice and Bob play a game. They have a binary string $s$ (a string such that each character in it is either $0$ or $1$). Alice moves first, then Bob, then Alice again, and so on.\n\nDuring their move, the player can choose any number (not less than one) of consecutive equal characters in $s$ and d... | 9 |
[
{
"content": "Given a permutation $p$ of length $n$, find its subsequence $s_1$, $s_2$, $\\ldots$, $s_k$ of length at least $2$ such that: $|s_1-s_2|+|s_2-s_3|+\\ldots+|s_{k-1}-s_k|$ is as big as possible over all subsequences of $p$ with length at least $2$. Among all such subsequences, choose the one whose ... | 10 |
[
{
"content": "You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. \n\nLet $Grid(s)$ be the grid of minim... | 11 |
[
{
"content": "Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:\n\nThere are two arrays of integers $a$ and $b$ of length $n$. It turned out that array $a$ contains only elements from the set $\\{-1, 0, 1\\}$.\n\nAnton can perform the following s... | 12 |
[
{
"content": "Your company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\n\nSkipping the repair is necessary because of the climate. The climate in your region... | 13 |
[
{
"content": "Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other words, check if it is possible to make a squa... | 14 |
[
{
"content": "Screen resolution of Polycarp's monitor is $a \\times b$ pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates $(x, y)$ ($0 \\le x < a, 0 \\le y < b$). You can consider columns of pixels to be numbered from $0$ to $a-1$, and rows — from $0$ to $b-1$.\n\nPolycarp wants to... | 15 |
[
{
"content": "Polycarp, Arkady's friend, prepares to the programming competition and decides to write a contest. The contest consists of $n$ problems and lasts for $T$ minutes. Each of the problems is defined by two positive integers $a_i$ and $p_i$ — its difficulty and the score awarded by its solution.\n\nPol... | 16 |
[
{
"content": "You are given an array $a_1, a_2 \\dots a_n$. Calculate the number of tuples $(i, j, k, l)$ such that: $1 \\le i < j < k < l \\le n$; $a_i = a_k$ and $a_j = a_l$; \n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\le t \\le 100$) — the number of test cases.\n\nThe first... | 17 |
[
{
"content": "The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, $n$ is always even, and in C2, $n$ is always odd.\n\nYou are given a regular polygon with $2 \\cdot n$ vertices (it's convex and has equal sides and equal angles) and all its sides... | 18 |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nThe BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le k$), where $a_i$ is the show, the episo... | 19 |
[
{
"content": "Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.\n\nGildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wa... | 20 |
[
{
"content": "Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.\n\nThere is a set $S$ contai... | 21 |
[
{
"content": "Let's define the following recurrence: $$a_{n+1} = a_{n} + minDigit(a_{n}) \\cdot maxDigit(a_{n}).$$\n\nHere $minDigit(x)$ and $maxDigit(x)$ are the minimal and maximal digits in the decimal representation of $x$ without leading zeroes. For examples refer to notes.\n\nYour task is calculate $a_{K}... | 22 |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nNow elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.\n\nThere are $n$ voters, and two ways to convince each of them to vote for you. The first way to convince the $i$-th ... | 23 |
[
{
"content": "Try guessing the statement from this picture: $3$ \n\nYou are given a non-negative integer $d$. You have to find two non-negative real numbers $a$ and $b$ such that $a + b = d$ and $a \\cdot b = d$.\n\n\n-----Input-----\n\nThe first line contains $t$ ($1 \\le t \\le 10^3$) — the number of test ca... | 24 |
[
{
"content": "We are committed to the well being of all participants. Therefore, instead of the problem, we suggest you enjoy a piece of cake.\n\nUh oh. Somebody cut the cake. We told them to wait for you, but they did it anyway. There is still some left, though, if you hurry back. Of course, before you taste t... | 25 |
[
{
"content": "You are given a special jigsaw puzzle consisting of $n\\cdot m$ identical pieces. Every piece has three tabs and one blank, as pictured below. $\\{3$ \n\nThe jigsaw puzzle is considered solved if the following conditions hold: The pieces are arranged into a grid with $n$ rows and $m$ columns. Fo... | 26 |
[
{
"content": "There are $n$ positive integers $a_1, a_2, \\dots, a_n$. For the one move you can choose any even value $c$ and divide by two all elements that equal $c$.\n\nFor example, if $a=[6,8,12,6,3,12]$ and you choose $c=6$, and $a$ is transformed into $a=[3,8,12,3,3,12]$ after the move.\n\nYou need to fin... | 27 |
[
{
"content": "Acacius is studying strings theory. Today he came with the following problem.\n\nYou are given a string $s$ of length $n$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string \"abacaba\" occu... | 28 |
[
{
"content": "You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.\n\nLet's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ ... | 29 |
[
{
"content": "You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's.\n\nString $s$ has exactly $\\frac{n}{2}$ zeroes and $\\frac{n}{2}$ ones ($n$ is even).\n\nIn one operation you can reverse any substring of $s$. A substring of a string is a contiguou... | 30 |
[
{
"content": "Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $1$ meter movement in the south, north, west or east direction respectively).\n\nIt is known that if he moves along a previously unvisited segment of a path (i.e. this seg... | 31 |
[
{
"content": "Lately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.\n\nThe game is played by two people taking turns, where Mr. Chanek takes the first turn. Initially, there is a tre... | 32 |
[
{
"content": "Numbers $1, 2, 3, \\dots n$ (each integer from $1$ to $n$ once) are written on a board. In one operation you can erase any two numbers $a$ and $b$ from the board and write one integer $\\frac{a + b}{2}$ rounded up instead.\n\nYou should perform the given operation $n - 1$ times and make the result... | 33 |
[
{
"content": "You have a large electronic screen which can display up to $998244353$ decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of $7$ segments which can be turned on and off to compose different digits. The following picture... | 34 |
[
{
"content": "Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying to form groups, but ran into some difficulties...\n\nMo... | 35 |
[
{
"content": "It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.\n\nMarmot brought Mole n ordered piles of worms such that i-th pile contains a_{i} worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a_1, worms in second ... | 36 |
[
{
"content": "Yeah, we failed to make up a New Year legend for this problem.\n\nA permutation of length $n$ is an array of $n$ integers such that every integer from $1$ to $n$ appears in it exactly once. \n\nAn element $y$ of permutation $p$ is reachable from element $x$ if $x = y$, or $p_x = y$, or $p_{p_x} = ... | 37 |
[
{
"content": "Two players decided to play one interesting card game.\n\nThere is a deck of $n$ cards, with values from $1$ to $n$. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between playe... | 38 |
[
{
"content": "After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are $n$ crossroads in the line in the town, and there is either the bus or the tram station at each crossroad.\n\nThe crossroads are represented as a string $s$ of length $... | 39 |
[
{
"content": "You are given a sequence $a_1, a_2, \\dots, a_n$, consisting of integers.\n\nYou can apply the following operation to this sequence: choose some integer $x$ and move all elements equal to $x$ either to the beginning, or to the end of $a$. Note that you have to move all these elements in one direct... | 40 |
[
{
"content": "You are fed up with your messy room, so you decided to clean it up.\n\nYour room is a bracket sequence $s=s_{1}s_{2}\\dots s_{n}$ of length $n$. Each character of this string is either an opening bracket '(' or a closing bracket ')'.\n\nIn one operation you can choose any consecutive substring of ... | 41 |
[
{
"content": "You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).\n\nLet $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ a... | 42 |
[
{
"content": "Petya is preparing for his birthday. He decided that there would be $n$ different dishes on the dinner table, numbered from $1$ to $n$. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.\n\nUnfortunately, all dishes are prepared in different restaurants and therefore ... | 43 |
[
{
"content": "Today the kindergarten has a new group of $n$ kids who need to be seated at the dinner table. The chairs at the table are numbered from $1$ to $4n$. Two kids can't sit on the same chair. It is known that two kids who sit on chairs with numbers $a$ and $b$ ($a \\neq b$) will indulge if: $gcd(a, b... | 44 |
[
{
"content": "Jett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.\n\nA staircase is a squared figure that consists of square cells. Each staircase consists of an arbitrary number of s... | 45 |
[
{
"content": "Recently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \\dots s_{n}$ of length $n$ where each letter is either R, S or P.\n\nWhile initializing, the bot is choosing a starting index $pos$ ($1 \\le p... | 46 |
[
{
"content": "This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.\n\nPikachu is a cute and friendly pokémon living in the wild pikachu herd.\n\nBut it has become known rec... | 47 |
[
{
"content": "You are playing a very popular game called Cubecraft. Initially, you have one stick and want to craft $k$ torches. One torch can be crafted using one stick and one coal.\n\nHopefully, you've met a very handsome wandering trader who has two trade offers: exchange $1$ stick for $x$ sticks (you lose... | 48 |
[
{
"content": "Let's call some positive integer classy if its decimal representation contains no more than $3$ non-zero digits. For example, numbers $4$, $200000$, $10203$ are classy and numbers $4231$, $102306$, $7277420000$ are not.\n\nYou are given a segment $[L; R]$. Count the number of classy integers $x$ s... | 49 |
[
{
"content": "Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were $2n$ jars of strawberry and blueberry jam.\n\nAll the $2n$ jars are arranged in a row. The stairs to the basement are exactly in the middle of that row. So when Karlsson ente... | 50 |
[
{
"content": "There are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. \n\nYou are an avid football fan, but recently you missed the whole k games. Fortunately, you remember a guess of your friend for these k games. Your friend did not tell exac... | 51 |
[
{
"content": "Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class tea... | 52 |
[
{
"content": "Gildong recently learned how to find the longest increasing subsequence (LIS) in $O(n\\log{n})$ time for a sequence of length $n$. He wants to test himself if he can implement it correctly, but he couldn't find any online judges that would do it (even though there are actually many of them). So in... | 53 |
[
{
"content": "You are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. \n\nYou may perform any number (possibly, zero) operations with this multiset.\n\nDuring each operation you choose two equal integers from $s$, remove them... | 54 |
[
{
"content": "A penguin Rocher has $n$ sticks. He has exactly one stick with length $i$ for all $1 \\le i \\le n$.\n\nHe can connect some sticks. If he connects two sticks that have lengths $a$ and $b$, he gets one stick with length $a + b$. Two sticks, that were used in the operation disappear from his set and... | 55 |
[
{
"content": "A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!\n\nYou are given integers $n,k$. Construct a grid $A$ with size $n \\times n$ consisting of integers $0$ and $1$. The very important condition should be satisfied: the sum of all elements in the grid is exactly $k$.... | 56 |
[
{
"content": "You are given an array $a$ of length $n$, which initially is a permutation of numbers from $1$ to $n$. In one operation, you can choose an index $i$ ($1 \\leq i < n$) such that $a_i < a_{i + 1}$, and remove either $a_i$ or $a_{i + 1}$ from the array (after the removal, the remaining parts are conc... | 57 |
[
{
"content": "You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar. \n\nIn one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: ho... | 58 |
[
{
"content": "Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers.\n\nDark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two... | 59 |
[
{
"content": "In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.\n\nTzuyu gave Sana two integers $a$ and $b$ and a really important quest.\n\nIn order to complete the quest, Sana has to output the smallest possible value of ($a \\oplus x$) + ($b \\oplus x$) for any given $x$, ... | 60 |
[
{
"content": "You are given a permutation $p_1, p_2, \\dots, p_n$. Recall that sequence of $n$ integers is called a permutation if it contains all integers from $1$ to $n$ exactly once.\n\nFind three indices $i$, $j$ and $k$ such that: $1 \\le i < j < k \\le n$; $p_i < p_j$ and $p_j > p_k$. Or say that ther... | 61 |
[
{
"content": "Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all $26$ lowercase Latin letters will be arranged in some order.\n\nPolycarp uses the same password $s$ on all websites where he is registered (it ... | 62 |
[
{
"content": "Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought $n$ integers, now it's time to distribute them between his friends rationally...\n\nLee has $n$ integers $a_1, a_2, \\ldots, a_n$ in his backpack and he has $k$ friends. Lee would like to distrib... | 63 |
[
{
"content": "There is a road with length $l$ meters. The start of the road has coordinate $0$, the end of the road has coordinate $l$.\n\nThere are two cars, the first standing at the start of the road and the second standing at the end of the road. They will start driving simultaneously. The first car will dr... | 64 |
End of preview. Expand in Data Studio
- Downloads last month
- 15