problem_id
stringlengths
32
32
name
stringlengths
2
112
problem
stringlengths
200
14k
test_cases
stringlengths
33
79.2M
difficulty
stringclasses
34 values
language
listlengths
1
1
source
stringclasses
15 values
num_solutions
int64
1
1.12M
starter_code
stringlengths
0
1.47k
subset
stringclasses
4 values
reasoning
stringlengths
1.09k
133k
deepseek_solution
stringlengths
60
15k
correctness
bool
2 classes
reason
stringclasses
3 values
1362627538d9eee04bfe245e5ac407a4
ism1
Hackers! Hackers! Everywhere! Some days back your email ID was hacked. Some one read the personal messages and Love Letters you sent to your girl friend. That's a terrible thing, well, you know how are the boys at ISM. So, you have decided that from now onwards you will write Love Letters to your girlfriend in a differ...
{"inputs": ["3\ncan you meet me outside ccd today\na\nthis year hard kaur is coming to entertain us", "3\ncan you meet me ouuside ccd today\na\nthis year hard kaur is coming to entertain us", "3\ncan you meet me ouuside ccd today\na\nthis xear hard kaur is coming to entertain us", "3\ncan you meet me ouuside ccd uoday\...
6
[ "PYTHON3" ]
1
2
code_contests
Okay, let's see. I need to solve this programming problem. The task is to reverse each word in a sentence, but with some conditions. Hmm, let's think about the example they gave. The input "i love you sweet heart" becomes "I evol uoy teews traeh". Wait, wait. Oh right! Each word is reversed. So "i" becomes "I" (capital...
To solve this problem, we need to reverse each word in a given sentence while maintaining the order of the words. The input consists of multiple test cases, each containing a line of lowercase alphabets separated by spaces. The goal is to reverse each word and output the transformed sentence for each test case. ### Ap...
false
Code is incorrect.
80921ecc087b5587a0e66d331a73884b
nopc10
Computation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calculate the day from a particular given date. You are required to find a day from a particular date given to you. Input It consists of a single line entry consisting of date in format dd mm yyyy. i.e. the input...
{"inputs": ["14 3 2012", "14 2 2012", "14 4 2012", "14 4 1177", "20 4 1177", "20 4 1433", "20 3 1433", "14 3 1433", "14 3 1186", "14 1 1186", "7 1 1186", "7 2 1186", "7 2 1946", "7 1 1946", "10 1 1946", "10 1 3808", "2 1 3808", "2 1 6973", "0 1 6973", "0 2 6973", "0 2 13465", "0 2 11195", "0 1 11195", "1 1 11195", "1 0...
6
[ "PYTHON3" ]
1
2
code_contests
Okay, I need to write a Python function that takes a date as input and outputs the corresponding day of the week. Let's think about how to approach this. The input is given as three integers: day, month, year. The output should be the day's name like Wednesday, Monday, etc. Hmm, Python has some built-in modules for d...
To solve this problem, we need to determine the day of the week for a given date. The input is provided in the format of day, month, and year, and we need to output the corresponding day name (e.g., Monday, Tuesday, etc.). ### Approach The approach involves using Python's `datetime` module to handle date-related calcu...
false
Code is incorrect.
40db3db8370ae846c1c465035afdcdf3
seg003
Problem description. The problem statement is simple , you are given an array and you have to perform two types of operation on it. Type 1 : update the value of array at the given index. Type 2 : find the maximum sum you can obtained in the given range ( L , R ) by taking any two index i and j , such that ( L <=...
{"inputs": ["5 3 \n1 2 3 4 5\n2 1 5\n1 2 5\n2 1 5"], "outputs": ["9 \n10"]}
6
[ "PYTHON3" ]
1
2
code_contests
Okay, let's try to solve this problem. So the problem is about performing two types of operations on an array. The first is updating a value, and the second is finding the maximum sum of two elements in a range where one is at an even position and the other at an odd position. Hmm. Wait, positions here—are they 1-base...
To solve this problem, we need to efficiently handle two types of operations on an array: updating a value at a specific index and finding the maximum sum of two elements in a given range where one element is at an even position and the other at an odd position. The challenge is to perform these operations efficiently ...
false
Code is incorrect.
f1301671002c44ea460612e1e40e4e9f
1003_D. Coins and Queries
Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d). Polycarp wants to know answers on q queries. The j-th query is described as integer number b_j. The answer to the query is the minimum number of...
{"inputs": ["5 4\n2 4 8 2 4\n8\n5\n14\n10\n", "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "1 10\n4\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "1 10\n2\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "1 10\n1\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "3 3\n1 1 1\n1\n2\n3\n", "4 1\n2 4 16 32\n14\n", "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n9\n16\n", "1 1...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about coins that are powers of two. Polycarp has n coins, each a_i is 2^d. For each query b_j, I have to find the minimum number of coins needed to sum up to b_j. If it's not possible, return -1. Hmm, the key here is to e...
To solve this problem, we need to determine the minimum number of coins required to form the value specified in each query using coins that are integer powers of 2. If it's not possible to form the value, we should return -1 for that query. ### Approach 1. **Input Reading and Preprocessing**: Read the input values eff...
true
6d19897861cd68fb80861c1fef9b7e26
1027_E. Inverse Coloring
You are given a square board, consisting of n rows and n columns. Each tile in it should be colored either white or black. Let's call some coloring beautiful if each pair of adjacent rows are either the same or different in every position. The same condition should be held for the columns as well. Let's call some col...
{"inputs": ["2 3\n", "1 1\n", "49 1808\n", "4 15\n", "4 2\n", "467 4\n", "4 11\n", "4 7\n", "3 1\n", "4 14\n", "500 125000\n", "3 7\n", "499 248999\n", "3 2\n", "4 9\n", "3 4\n", "2 2\n", "4 12\n", "499 249001\n", "4 5\n", "499 249000\n", "4 13\n", "3 8\n", "467 1\n", "4 8\n", "4 6\n", "2 1\n", "4 1\n", "2 4\n", "3 6\n...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about counting the number of suitable colorings of an n x n board. A coloring is suitable if it's beautiful and has no rectangles of a single color with at least k tiles. Let's break down the definitions. First, a beautif...
To solve this problem, we need to count the number of suitable colorings of an n x n board where a coloring is suitable if it is beautiful and contains no monochromatic rectangle of at least k tiles. A beautiful coloring requires that each pair of adjacent rows and columns are either the same or inverses of each other....
false
Code is incorrect.
11fd7d796534acf0e6c2ffcc2000ffb0
1046_D. Interstellar battle
In the intergalactic empire Bubbledom there are N planets, of which some pairs are directly connected by two-way wormholes. There are N-1 wormholes. The wormholes are of extreme religious importance in Bubbledom, a set of planets in Bubbledom consider themselves one intergalactic kingdom if and only if any two planets ...
{"inputs": ["5\n0.50 0.29 0.49 0.95 0.83\n2 3\n0 3\n3 4\n2 1\n3\n4 0.66\n1 0.69\n0 0.36\n", "26\n0.98 0.64 0.06 0.90 0.01 0.73 0.21 0.98 0.65 1.00 0.87 0.85 0.01 0.06 0.65 0.00 0.65 0.40 0.71 0.80 0.66 0.16 0.54 0.39 0.21 0.29\n20 21\n9 23\n9 0\n17 13\n16 20\n1 8\n9 4\n22 15\n14 17\n14 6\n2 16\n5 19\n11 23\n2 14\n12 10...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. We need to calculate the expected number of connected components after each attack. The initial setup is a tree with N nodes. When each node is removed with some probability p_i, the remaining graph is a forest, and we have to find the expected number of connected components. Hmm. The key here is to m...
To solve this problem, we need to calculate the expected number of connected components in a tree structure after each attack, where each node has a probability of being removed. The solution involves efficiently maintaining and updating the expected values as the probabilities change. ### Approach 1. **Understanding ...
false
Code is incorrect.
646b6557475f3ad62a7c2eae927b50a2
1070_C. Cloud Computing
Buber is a Berland technology company that specializes in waste of investor's money. Recently Buber decided to transfer its infrastructure to a cloud. The company decided to rent CPU cores in the cloud for n consecutive days, which are numbered from 1 to n. Buber requires k CPU cores each day. The cloud provider offer...
{"inputs": ["7 13 5\n2 3 10 7\n3 5 10 10\n1 2 10 6\n4 5 10 9\n3 4 10 8\n", "4 100 3\n3 3 2 5\n1 1 3 2\n2 4 4 4\n", "5 7 3\n1 4 5 3\n1 3 5 2\n2 5 10 1\n", "5 2 5\n3 5 2 1\n2 3 1 4\n1 4 3 1\n2 3 1 2\n2 3 1 5\n", "2 1 1\n1 2 1 1\n", "1 2 1\n1 1 3 1\n", "2 1 5\n1 1 1 4\n2 2 1 1\n1 2 1 1\n1 2 1 3\n2 2 1 2\n", "5 1 5\n1 5 1 ...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So, the problem is about Buber renting CPU cores over n days. Each day they need k cores. There are m tariff plans. Each plan is available from day l_i to r_i. Each day during that period, they can rent up to c_i cores at price...
To solve this problem, we need to determine the minimum cost for Buber to rent CPU cores over a series of days, considering various tariff plans. Each plan has different availability periods, core limits, and prices. The goal is to minimize the total cost by efficiently utilizing the cheapest available plans first. ##...
true
369ff59f422232b72aeae05a0e8824f0
1091_G. New Year and the Factorisation Collaboration
Integer factorisation is hard. The RSA Factoring Challenge offered $100 000 for factoring RSA-1024, a 1024-bit long product of two prime numbers. To this date, nobody was able to claim the prize. We want you to factorise a 1024-bit number. Since your programming language of choice might not offer facilities for handli...
{"inputs": ["21\n\n7\n\n17\n\n15\n\n17\n\n11\n\n-1\n\n15\n\n", "3\n230967221047542071272908186525868331398921682471308664253988778356539397562182960087 182611080502122916090565666030857827681271950069759605734177210648361435031281924911 20558124518720812021713072667920464230570676159940964371555251615699135858693492398...
13
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to factorize a number n which is a product of 2 to 10 primes all congruent to 3 mod 4. The challenge is to do this using the provided calculator operations, with a limited number of queries (up to 100). Let's think about possible approaches. First, since all primes are 3 mod 4, that gives some properties....
To solve this problem, we need to factorize a large integer \( n \) which is a product of 2 to 10 distinct prime numbers, each of the form \( 4x + 3 \). The challenge is to use a limited set of calculator operations to determine these prime factors efficiently. ### Approach The key insight is to leverage the propertie...
false
Code is incorrect.
3c1a543f40721ce54505caa8ffd2414b
1110_E. Magic Stones
Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≤ i ≤ n - 1), and after that synchronizes it with neighboring stones. After that, the chosen stone loses its ...
{"inputs": ["4\n7 2 4 12\n7 15 10 12\n", "3\n4 4 4\n1 2 3\n", "10\n62159435 282618243 791521863 214307200 976959598 590907019 166397456 708291256 85377387 569889619\n296371399 546807332 272720717 689420404 273026579 74510326 749070707 104458586 450770185 466655231\n", "7\n12 9 8 6 9 12 84\n12 9 8 5 9 12 84\n", "2\n1 3\...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, so I have this programming problem to solve. Let's read the problem carefully. The task is to determine if we can transform Grigory's stones into Andrew's stones by performing some synchronization operations. The synchronization operation involves selecting an inner stone (not the first or last) and changing its ...
To solve this problem, we need to determine if we can transform Grigory's stones into Andrew's stones using a series of synchronization operations. The key insight is that these operations allow us to permute the differences between adjacent stones, but not change their values. Thus, the solution involves checking if t...
false
Code is incorrect.
30475d77ef4e1df21aa0c23a81ff2958
1140_B. Good String
You have a string s of length n consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the l...
{"inputs": ["3\n2\n&lt;&gt;\n3\n&gt;&lt;&lt;\n1\n&gt;\n", "1\n9\n>>>>>>>><\n", "13\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n", "14\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n", "3\n2\n<>\n3\n><<\n1\n>\n", "13\n1\n>\n1\n?\n1\n>\n1\n>\n1\n>\n...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The task is to find the minimum number of characters to delete from a string composed of '>' and '<' such that the remaining string is "good". A good string can be reduced to a single character through a series of operations. T...
To solve this problem, we need to determine the minimum number of characters to delete from a string composed of '>' and '<' such that the remaining string can be reduced to a single character through a series of operations. The operations involve choosing a character and deleting either the next or previous character ...
true
90384a211601de42db9ab19d5fbdec7e
1158_F. Density of subarrays
Let c be some positive integer. Let's call an array a_1, a_2, …, a_n of positive integers c-array, if for all i condition 1 ≤ a_i ≤ c is satisfied. Let's call c-array b_1, b_2, …, b_k a subarray of c-array a_1, a_2, …, a_n, if there exists such set of k indices 1 ≤ i_1 < i_2 < … < i_k ≤ n that b_j = a_{i_j} for all 1 ≤...
{"inputs": ["5 2\n1 2 1 2 1\n", "3 3\n1 2 3\n", "4 1\n1 1 1 1\n", "2 1\n1 1\n", "2 3\n3 1\n", "100 5\n5 5 2 4 5 4 4 4 4 2 5 3 4 2 4 4 1 1 5 3 2 2 1 3 3 2 5 3 4 5 1 3 5 4 4 4 3 1 4 4 3 4 5 2 5 4 2 1 2 2 3 5 5 5 1 4 5 3 1 4 2 2 5 1 5 3 4 1 5 1 2 2 3 5 1 3 2 4 2 4 2 2 4 1 3 5 2 2 2 3 3 4 3 2 2 5 5 4 2 5\n", "11 3\n1 3 2 1...
12
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. We need to calculate, for each possible p (from 0 to n), the number of subsequences of the given array such that the density of that subsequence is exactly p. Then, output all these counts modulo 998244353. First, let's clarify what density means here. The density of a c-arr...
To solve this problem, we need to determine the number of subsequences of a given array that have a specific density. The density of an array is defined as the maximum length of all possible sequences that can be formed as a subsequence of the array. The solution involves dynamic programming and combinatorial mathemati...
true
5b085f4472b563a0865a9a38e2a004dc
1180_E. Serge and Dining Room
Serge came to the school dining room and discovered that there is a big queue here. There are m pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. As Serge is very tired, he asks you to compute it instead of him. Initially t...
{"inputs": ["1 1\n1\n1\n1\n2 1 100\n", "4 6\n1 8 2 4\n3 3 6 1 5 2\n3\n1 1 1\n2 5 10\n1 1 6\n", "1 1\n1\n1\n1\n1 1 100\n", "4 1\n7 6 1 1\n3\n3\n2 1 9\n2 1 10\n2 1 6\n", "5 1\n8 4 8 7 3\n9\n5\n2 1 3\n1 5 1\n2 1 8\n2 1 7\n2 1 3\n", "3 5\n3 2 8\n1 2 8 1 1\n4\n1 3 3\n1 2 2\n2 2 10\n1 1 5\n", "4 1\n7 6 1 2\n3\n3\n2 1 9\n2 1 ...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. We need to solve this problem where after each query, we have to determine which dish Serge will get. The key points are understanding how the pupils buy the dishes and how the queries affect the state. So the setup is: there are n dishes and m pupils. Each pupil in the queue will buy the most expensi...
To solve this problem, we need to determine the most expensive dish Serge will get after all pupils have bought their dishes, considering dynamic updates to dish prices and pupils' money. The solution must efficiently handle these updates and provide the result after each query. ### Approach 1. **Data Structures**: Us...
false
Code is incorrect.
6e2c64009851c6b0213815a620ab0c0f
1199_E. Matching vs Independent Set
You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an independent set if no two vertices are connected with an edge. Input The first line...
{"inputs": ["4\n1 2\n1 3\n1 2\n1 2\n1 3\n1 2\n2 5\n1 2\n3 1\n1 4\n5 1\n1 6\n2 15\n1 2\n1 3\n1 4\n1 5\n1 6\n2 3\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n4 5\n4 6\n5 6\n", "1\n5 39\n1 2\n3 4\n5 6\n7 8\n1 9\n3 10\n3 11\n5 12\n5 13\n7 14\n7 15\n9 2\n10 2\n11 2\n12 2\n13 2\n14 2\n15 2\n9 4\n10 4\n11 4\n12 4\n13 4\n14 4\n15 4\n9 6\n10...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, so I've got this programming problem to solve. Let me read through it carefully. The task is, given a graph with 3n vertices and m edges, to find either a matching of size n or an independent set of size n. Hmm. First, let me understand the definitions again. A matching is a set of edges where none share a verte...
To solve this problem, we need to determine either a matching of size `n` or an independent set of size `n` in a graph with `3n` vertices and `m` edges. The solution leverages the properties of maximal matchings and independent sets to ensure that at least one of these structures exists. ### Approach 1. **Maximal Matc...
false
Code is incorrect.
afa689048db3854af8e1b531f4058add
1216_D. Swords
There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swo...
{"inputs": ["2\n2 9\n", "3\n3 12 6\n", "7\n2 1000000000 4 6 8 4 2\n", "6\n13 52 0 13 26 52\n", "10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n", "10\n1 1000000000 1 1 1 1 1 1 1 1\n", "5\n0 0 1 0 0\n", "10\n1000000000 1 2 3 4 5 6 7 8 9\n", "3\n1000000000 1 1000000000\...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding the minimum number of people y and the value z (the number of swords each took) such that each person took exactly z swords of a single type. The initial number of swords for each type was x, and...
To solve this problem, we need to determine the minimum number of people who could have broken into the theater basement and the number of swords each person took. The solution involves analyzing the remaining swords of each type and using mathematical operations to derive the required values efficiently. ### Approach...
true
ab296b0ee112044e0121dbaa79e1b3df
1239_E. Turtle
Kolya has a turtle and a field of size 2 × n. The field rows are numbered from 1 to 2 from top to bottom, while the columns are numbered from 1 to n from left to right. Suppose in each cell of the field there is a lettuce leaf. The energy value of lettuce leaf in row i and column j is equal to a_{i,j}. The turtle is i...
{"inputs": ["3\n1 0 1\n0 0 0\n", "2\n1 4\n2 3\n", "3\n0 0 0\n0 0 0\n", "25\n11632 6805 12792 25513 4573 48789 42308 23247 17502 23125 43597 22173 45527 8637 33001 23532 16047 26169 49458 32012 44865 11178 34515 12381 2780\n21476 20495 26007 43987 19150 12922 29730 13310 19333 34685 25982 10775 25880 20230 34685 37998 3...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where I have to rearrange the lettuce leaves in a 2xN grid such that the maximum path sum that the turtle takes is as small as possible. The turtle starts at the top-left cell (1,1) and moves to the bottom-right cell (2,n), moving only right and down. And the path chosen is the one...
To solve this problem, we need to reorder the lettuce leaves in a 2×n grid such that the maximum energy value consumed by the turtle along its path from the top-left to the bottom-right cell is minimized. The turtle can only move right and down, and it will choose the path with the maximum energy value. Our goal is to ...
false
Code is incorrect.
e6c674ab6a7b77e47a8f112a041c07dd
1257_G. Divisor Set
You are given an integer x represented as a product of n its prime divisors p_1 ⋅ p_2, ⋅ … ⋅ p_n. Let S be the set of all positive integer divisors of x (including 1 and x itself). We call a set of integers D good if (and only if) there is no pair a ∈ D, b ∈ D such that a ≠ b and a divides b. Find a good subset of S ...
{"inputs": ["3\n2999999 43 2999957\n", "6\n2 3 2 3 2 2\n", "16\n2 2 2 2 2 3 3 3 3 5 5 7 7 11 13 17\n", "16\n2 2 2 2 2 2 2 2 3 3 5 5 7 11 13 17\n", "16\n2 2 2 2 2 2 3 3 3 5 5 7 7 11 13 17\n", "16\n2 2 2 2 2 2 3 3 3 3 3 5 7 11 13 17\n", "1\n2999999\n", "16\n2 2 2 2 2 2 2 2 2 3 3 5 7 11 13 17\n", "16\n2 2 2 3 3 3 5 5 5 7 ...
13
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. So the problem is about finding the maximum size of a 'good' subset of the divisors of a number x. The definition of a good subset is that no two distinct elements in the subset have one dividing the other. The input gives the prime fact...
To solve this problem, we need to determine the maximum size of a good subset of divisors of a number \( x \) represented by its prime factors. A good subset is defined as a set where no element divides another. The solution involves finding the largest antichain in the poset of divisors under divisibility, which corre...
true
1c57bf54a7117382933986666d8a53cd
1281_B. Azamon Web Services
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the search engines. If only he could rename his products to have better ...
{"inputs": ["3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n", "3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n", "3\nAZAMON APPLE\nAZOMAN AAAAAAAAAAALIBABA\nAPPLE BANANA\n", "3\nAZAMNO ELPPA\nAZAMON AAAAAAAAAAALIBABA\nAPPLE BANANA\n", "3\nAZAMON APPLE\nAZAMON AAAAAAAAAAALIBABA\nAPPLF ANANAB\n", "3\...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So the task is to find if we can swap at most one pair of characters in string s such that the new string is lexicographically smaller than string c. If possible, output the smallest possible such string; otherwise, output three dashes. Hmm. Let's break down the problem. First, I need ...
To solve this problem, we need to determine if we can swap at most one pair of characters in Jeff's product name (string `s`) to make it lexicographically smaller than his competitor's product name (string `c`). If possible, we should output the modified string; otherwise, output "---". ### Approach 1. **Immediate Che...
false
Code is incorrect.
2ae34b2c9f679730d4824fbf5d6a1fae
1301_B. Motarack's Birthday
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. Dark 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 adjacent elements with a high...
{"inputs": ["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n", "7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 5 2 -1 5\n", "7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. So the problem is about an array a where some elements are missing (marked as -1). We need to replace all missing elements with the same integer k, such that the maximum absolute difference between adjacent elements is minimiz...
To solve this problem, we need to determine the optimal integer `k` to replace all missing elements (denoted as -1) in an array such that the maximum absolute difference between adjacent elements (m) is minimized. ### Approach 1. **Identify Pairs and Adjacent Elements**: - **Pairs**: Identify pairs of known elemen...
false
Code is incorrect.
207baf27959e44e4ac4e9948743c397d
1325_B. CopyCopyCopyCopyCopy
Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence? A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (pos...
{"inputs": ["2\n3\n3 2 1\n6\n3 1 4 1 5 9\n", "1\n5\n1 3 4 5 2\n", "1\n3\n1 1 274005660\n", "4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 5 9 8 7\n7\n1 2 7 1 6 10 2\n", "2\n3\n1 1 1\n2\n1 1\n", "2\n2\n1 1\n1\n1\n", "2\n5\n5 5 5 5 5\n3\n1 2 5\n", "2\n5\n1 2 3 4 5\n4\n2 3 4 5\n", "2\n4\n1 3 3 3\n3\n1 2 3\n", "1\n5\n2 3 4 5 2\n", "1\n3...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about finding the longest increasing subsequence (LIS) in a new array formed by concatenating the original array n times. Hmm. So, the original array is of length n, and we make n copies of it. So the new array has length n^2. But directly computing the LIS for such a large array isn't f...
To solve this problem, we need to determine the length of the longest increasing subsequence (LIS) in an array formed by concatenating the original array `n` times, where `n` is the length of the original array. The key insight is that the maximum possible LIS in the concatenated array is determined by the number of di...
true
b5bfc4ef9dc1ae1328575781a80c4574
1344_A. Hilbert's Hotel
Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself,...
{"inputs": ["6\n1\n14\n2\n1 -1\n4\n5 5 5 1\n3\n3 2 1\n2\n0 1\n5\n-239 -2 -100 -3 -11\n", "10\n3\n-15 -33 79\n16\n45 -84 19 85 69 -64 93 -70 0 -53 2 -52 -55 66 33 -60\n2\n14 -2\n4\n-65 -76 5 25\n5\n55 -66 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 88 -25 96 22 -44\n", "10\n1\n1000000...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to solve this problem. Hmm, the problem is about checking whether after shuffling the guests according to the given array a, each room ends up with exactly one guest. So, the key is to determine if the mapping from k to k + a_{k mod n} is a bijection (both injective and surjective) over all integers. W...
To solve this problem, we need to determine if after shuffling guests in Hilbert's Hotel according to a given array, each room still contains exactly one guest. The key insight is that the function mapping guests to new rooms must be a bijection, ensuring no two guests end up in the same room and no room is left vacant...
true
6f3d1794f0ed9918df732e03b99ed4c3
1366_A. Shovels and Swords
Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick. Each tool can be sold for exactly one emerald. How many...
{"inputs": ["4\n4 4\n1000000000 0\n7 15\n8 7\n", "1\n656 656\n", "1\n666 666\n", "2\n7 4\n1 5\n", "1\n33993 5\n", "1\n1656 5\n", "1\n1319 1777\n", "1\n667 666\n", "1\n656 281\n", "1\n666 760\n", "2\n10 4\n1 5\n", "1\n33993 6\n", "1\n1656 9\n", "1\n1425 1777\n", "1\n667 288\n", "4\n4 4\n1000000000 0\n12 15\n8 7\n", "1\n...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is about crafting tools using sticks and diamonds. Each tool gives one emerald. The two types are shovels and swords. A shovel needs 2 sticks and 1 diamond. A sword needs 2 diamonds and 1 stick. We need to find the maximum number of tools (emeralds) Polycarp can make given a sticks and b...
To solve this problem, we need to determine the maximum number of tools (shovels and swords) that Polycarp can craft using given numbers of sticks and diamonds. Each tool requires either two sticks and one diamond (for a shovel) or two diamonds and one stick (for a sword). Each tool can be sold for one emerald. The sol...
true
195db11a6ffd60b8a4a9e0a4a4c4d14f
1386_A. Colors
Linda likes to change her hair color from time to time, and would be pleased if her boyfriend Archie would notice the difference between the previous and the new color. Archie always comments on Linda's hair color if and only if he notices a difference — so Linda always knows whether Archie has spotted the difference o...
{"inputs": ["1\n\n7\n\n1\n\n1\n\n0\n\n0\n\n1\n", "46\n63 1\n63 63\n123 1\n123 123\n63 2\n63 62\n123 2\n123 122\n63 3\n63 61\n123 3\n123 121\n63 4\n63 60\n123 4\n123 120\n63 5\n63 59\n123 5\n123 119\n66 65\n80 30\n114 107\n95 66\n87 83\n103 40\n71 65\n72 48\n104 93\n93 14\n65 61\n118 4\n75 68\n108 26\n97 94\n106 5\n84 8...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about determining the critical value C such that Archie notices the difference between consecutive hair colors if their absolute difference is at least C. The challenge is to find C with a limited number of queries, up to 64, even for very large N (like up to 1e18). First, let's unders...
To solve this problem, we need to determine the critical value \( C \) such that Archie notices the difference between consecutive hair colors if and only if the absolute difference is at least \( C \). The challenge is to find \( C \) efficiently using a limited number of queries, even for very large values of \( N \)...
false
Code is incorrect.
82e528a863b9828c8d57388822dbf252
1408_A. Circle Coloring
You are given three sequences: a_1, a_2, …, a_n; b_1, b_2, …, b_n; c_1, c_2, …, c_n. For each i, a_i ≠ b_i, a_i ≠ c_i, b_i ≠ c_i. Find a sequence p_1, p_2, …, p_n, that satisfy the following conditions: * p_i ∈ \\{a_i, b_i, c_i\} * p_i ≠ p_{(i mod n) + 1}. In other words, for each element, you need to choose ...
{"inputs": ["5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n", "5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to generate a sequence p such that each element p_i is chosen from a_i, b_i, c_i, and no two adjacent elements are the same, including the first and last elements since it's a circle. The problem says that a solution always exists, so I don't have to worry about impossibl...
To solve this problem, we need to construct a sequence from three given sequences such that no two adjacent elements (including the first and last elements) are the same. The solution must ensure that each element in the resulting sequence is chosen from the corresponding elements of the three given sequences. ### App...
false
Code is incorrect.
d57f00bd7b87cf667fdcd1a04a6d0854
1428_D. Bouncing Boomerangs
To improve the boomerang throwing skills of the animals, Zookeeper has set up an n × n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to n from left to right. For each column, Zookeeper will t...
{"inputs": ["1\n0\n", "6\n2 0 3 0 1 1\n", "6\n3 2 2 2 1 1\n", "6\n0 1 3 2 1 2\n", "4\n1 2 3 1\n", "4\n1 1 1 2\n", "4\n3 3 2 1\n", "4\n1 2 1 1\n", "4\n1 1 2 1\n", "1\n3\n", "6\n1 3 2 0 3 1\n", "4\n1 3 2 1\n", "4\n2 3 1 1\n", "4\n3 1 1 1\n", "4\n3 2 3 1\n", "4\n2 1 2 1\n", "6\n0 2 1 3 2 3\n", "4\n1 3 3 1\n", "4\n2 3 3 1\...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to solve this problem. Hmm. So the problem is about placing targets in an n x n grid such that each row and column has at most 2 targets. Then, for each column, when a boomerang is thrown upwards from the bottom, it hits exactly a_i targets. We need to construct such a configuration or return -1 if it's...
To solve this problem, we need to construct a valid configuration of targets in an n x n grid such that each column's boomerang throws hit the specified number of targets, while adhering to the constraints that each row and column can have at most two targets each. ### Approach 1. **Input Validation**: Ensure all valu...
false
Code is incorrect.
741c8beffa4fa3d5bd6f5fe57341a6be
1451_D. Circle Game
Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the...
{"inputs": ["5\n2 1\n5 2\n10 3\n25 4\n15441 33\n", "5\n2 1\n5 2\n10 3\n25 4\n25479 33\n", "5\n2 1\n9 1\n10 3\n25 4\n25479 33\n", "5\n1 1\n9 1\n10 3\n46 4\n25479 33\n", "5\n2 1\n5 1\n10 3\n25 3\n25479 33\n", "5\n2 1\n9 1\n10 3\n25 4\n25479 57\n", "5\n2 1\n9 1\n11 3\n25 4\n25479 57\n", "5\n2 1\n4 1\n10 3\n46 4\n25479 47\...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about a game between Ashish and Utkarsh. They take turns moving a token on a 2D plane. The token starts at (0,0). Each move involves increasing either the x or y coordinate by exactly k. But after each move, the new position (p,q) must satisfy p² + q² ≤ d². The player who can't move lose...
To solve this problem, we need to determine the winner of a game played between Ashish and Utkarsh on a 2D plane. The game involves moving a token from (0,0) by increasing either the x or y coordinate by exactly k units each turn, while ensuring the token remains within a Euclidean distance d from the origin. The playe...
true
a2a7d6e29dbeef0061e85bfedd6f45e7
1475_D. Cleaning the Phone
Polycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory. Polycarp wants to free at least m units of memory (by removing some applications). Of course, some applications are more important to Polycarp than others. He came up with the fol...
{"inputs": ["5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 2 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2 1 2\n2 1 2 1\n", "1\n17 20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2\n", "5\n5 7\n5 3 2 1 4\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 2 3 2\n1 1 1 2 1\n4 10\n5 1 3 4\n1 2 1 2\n4 5\n3 2...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I have this programming problem to solve. Let's read it carefully. The problem says that Polycarp wants to delete some apps to free at least m units of memory. Each app has a memory a_i and a convenience score b_i which is either 1 or 2. We need to find the minimum total of b_i's for the apps removed, such th...
To solve this problem, we need to determine the minimum number of convenience points Polycarp will lose by removing applications to free at least a specified amount of memory. The solution involves a systematic approach to efficiently find the optimal set of applications to remove. ### Approach 1. **Separate Applicati...
true
74037d2a430b8d8313bbc040fe837abe
1500_B. Two chandeliers
Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r...
{"inputs": ["3 8 41\n1 3 2\n1 6 4 3 5 7 2 8\n", "1 2 31\n1\n1 2\n", "4 2 4\n4 2 3 1\n2 1\n", "20 101 100\n1 14 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 93 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 6 15 99 79 16 22 56 19 60 61 85 28 65 8 23 46 39 25 48 36 64 98 37 27 45 1...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is to find the k-th day where the two chandeliers have different colors. Hmm. So each day, the first chandelier cycles through its colors in order, and the second does the same. We need to find the day number when the k-th difference occurs. First, I need to figure out for each day whether...
To solve this problem, we need to determine the k-th day when the colors of two different chandeliers differ. The chandeliers cycle through their colors in a periodic manner, and we need an efficient way to compute the day without checking each day individually. ### Approach 1. **Identify Valid Color Matches**: First,...
true
7bb20a9d9bde75db9c5b9bec143c80bc
1525_D. Armchairs
There are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2. For some reason, you would like to tell people to move from their armchairs to some other ones. If the i-th ...
{"inputs": ["6\n1 1 1 0 0 0\n", "5\n0 0 0 0 0\n", "7\n1 0 0 1 0 0 1\n", "100\n0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0\n", "2\n1 0\n", "2\n0 0\n", "100\n1 1 0 1 ...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out this problem. So the task is to move people from their initially occupied chairs such that all those chairs become free. And we need to find the minimum total time required, considering that each move is done sequentially, so the total time is the sum of each individual move's time. Wait, ...
To solve this problem, we need to move people from their initially occupied armchairs to other armchairs such that all initially occupied armchairs become free. The goal is to minimize the total time spent moving people, where each move is done sequentially and the time for each move is the absolute distance between th...
true
061b0aba62d36e3ca2c2414f23f7037b
157_A. Game Outcome
Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they need to count the number...
{"inputs": ["1\n1\n", "2\n1 2\n3 4\n", "4\n5 7 8 4\n9 5 3 2\n1 6 6 4\n9 5 7 3\n", "9\n53 80 94 41 58 49 88 24 42\n85 11 32 64 40 56 63 95 73\n17 85 60 41 13 71 54 67 87\n38 14 21 81 66 59 52 33 86\n29 34 46 18 19 80 10 44 51\n4 27 65 75 77 21 15 49 50\n35 68 86 98 98 62 69 52 71\n43 28 56 91 89 21 14 57 79\n27 27 29 26...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let me read the problem statement carefully again. So the problem is about a game played on an n x n grid. Each square has a number. For each square, I have to calculate the sum of its column and the sum of its row. If the column sum is strictly greater than the row sum,...
To solve this problem, we need to determine the number of winning squares on an n x n grid where a square is considered winning if the sum of its column is strictly greater than the sum of its row. ### Approach 1. **Read Input**: First, read the integer `n` which represents the size of the grid. Then read the next `n`...
true
922e52eb45f84b091c95a35670ce46e6
178_A1. Educational Game
The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. some prefix of the sequenc...
{"inputs": ["8\n1 2 3 4 5 6 7 8\n", "4\n1 0 1 2\n", "80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100 34 3 24 58 11 85 73 18 4 45 90 99 42 85 26 71 58 49 76 32 88 13 40 98 57 95 20 36 70 66 75 12 54 96\n", "80\n72 66 82 46 44 2...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let me read the problem statement carefully. The problem is about finding, for each k from 1 to n-1, the minimum number of moves required to make the first k elements of the array all zero. The moves allowed are choosing an index i and a t such that i + 2t <= n. Then, de...
To solve this problem, we need to determine the minimum number of moves required to make the first k elements of a given sequence zero for each possible k (1 ≤ k < n). Each move allows transferring a unit from position i to position i + 2t, where t is a non-negative integer and i + 2t ≤ n. ### Approach The key insight...
false
Code is incorrect.
ca005188dd79e361933fd6c0171e8f89
19_B. Checkout Assistant
Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupied with some item, Bob can steal some other items from his trolley. ...
{"inputs": ["4\n2 10\n0 20\n1 5\n1 3\n", "3\n0 1\n0 10\n0 100\n", "5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n", "5\n0 51690939\n0 62436494\n0 39009053\n0 70426298\n0 631569476\n", "5\n5 491957578\n4 747764103\n3 446810728\n4 896625835\n4 190748656\n", "2\n2 87623264\n0 864627704\n", "10\n3 512...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, Bob is at a store with some items. Each item has a time ti that the checkout assistant takes to process it and a cost ci. While the assistant is processing an item, Bob can steal others. But stealing takes 1 second per item. Also, if ti is 0, then during the processing of...
To solve this problem, we need to determine the minimum amount of money Bob will have to pay to the checkout assistant while stealing as many items as possible. The key is to find the optimal order of processing items such that Bob can steal the maximum number of items while minimizing the total cost of the items he pa...
true
20c388490676a38a07511f8c3dbd815d
223_C. Partial Sums
You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that: 1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that ...
{"inputs": ["5 0\n3 14 15 92 6\n", "3 1\n1 2 3\n", "10 1000000\n1 2 3 4 84 5 6 7 8 9\n", "1 1\n3\n", "13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200\n", "1 0\n0\n", "42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42\n", "4 1\n3 ...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem says that we have an array a of n integers. We perform a two-step operation k times. Each operation involves first creating an array s of partial sums modulo (1e9 +7?), wait, the problem statement says that in the f...
To solve this problem, we need to determine the state of an array after applying a specific operation exactly `k` times. The operation involves computing the partial sums of the array elements modulo \(10^9 + 7\) and then replacing the original array with these partial sums. Given the constraints, a direct simulation o...
true
2ac8d514dfdc168544ada654fa66d762
248_A. Cupboards
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house. Karlsson's gaze immediately fell on n wooden ...
{"inputs": ["5\n0 1\n1 0\n0 1\n1 1\n0 1\n", "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n", "8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n", "2\n0 0\n0 0\n", "3\n0 1\n1 1\n1 1\n", "5\n1 0\n1 0\n1 0\n0 1\n0 1\n", "15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "8\n0 1\n1 0\n0 1\n1 1\n0 0\...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So, the task is to find the minimum time Karlsson needs to adjust all cupboard doors so that all left doors are in the same state (either all open or all closed) and all right doors are the same. Each door change takes 1 second per door. Hmm. So for each cupboard, there are two doors: ...
To solve this problem, we need to determine the minimum number of seconds Karlsson needs to adjust all cupboard doors such that all left doors are in the same state (either all open or all closed) and all right doors are in the same state. Each door change takes 1 second. ### Approach 1. **Problem Analysis**: Karlsson...
true
af0ca9121a5dc494fe535749a64ad364
272_B. Dima and Sequence
Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence: * f(0) = 0; * f(2·x) = f(x); * f(2·x + 1) = f(x) + 1. Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤...
{"inputs": ["3\n1 2 4\n", "3\n5 3 1\n", "6\n396640239 62005863 473635171 329666981 510631133 207643327\n", "4\n363034183 741262741 657823174 453546052\n", "2\n7 1\n", "1\n1\n", "2\n1 1\n", "8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n", "8\n7 1 2 7 6 8 6 5\n", "2\n469264357 99656949...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to count the number of pairs (i, j) such that i < j and the function f(a_i) equals f(a_j). Let's start by understanding what this function f does. The function f is defined recursively. Let's see the recurrence relations again: - f(0) = 0 - f(2x) = f(x) - f(2x + 1) = f(...
To solve this problem, we need to count the number of pairs of indices (i, j) such that the function f(a_i) equals f(a_j), where f(x) is defined based on a recurrence relation. Through analysis, we determined that f(x) corresponds to the number of 1s in the binary representation of x. Using this insight, we can efficie...
true
c8c3a5eaea5f8e7d87953ca72ca1bf46
295_D. Greg and Caves
Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right. Greg thinks that the pad's screen displays a c...
{"inputs": ["3 5\n", "1 1\n", "4 4\n", "5 3\n", "1500 2000\n", "500 1000\n", "1000 1000\n", "5 5\n", "2000 2\n", "1000 500\n", "3 1000\n", "2000 1\n", "1 2\n", "3 1999\n", "100 100\n", "1 1000\n", "1000 3\n", "7 8\n", "9 8\n", "10 10\n", "2000 1777\n", "1000 1\n", "100 200\n", "10 500\n", "1998 4\n", "2 2000\n", "10 10...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to tackle this problem. Hmm, the problem is about counting the number of ways to paint a cave on Greg's pad. The definition of a cave is a bit complex, so I need to parse the conditions carefully. First, the cave must have a segment of rows [l, r] where each row in this segment has exactly two black ce...
To solve this problem, we need to determine the number of ways to paint a cave on Greg's pad according to specific conditions. The solution involves dynamic programming (DP) with optimized prefix sums to efficiently compute the valid configurations. ### Approach 1. **Problem Analysis**: - A cave is defined by a seg...
false
Code is incorrect.
845588b47738a7fc311e7fa9da2ee464
319_B. Psychos in a Line
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. You're given the initial arrangeme...
{"inputs": ["6\n1 2 3 4 5 6\n", "10\n10 9 7 8 6 5 3 4 2 1\n", "2\n1 2\n", "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 4...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to find the number of steps until no more psychos are killing their right neighbors. Let's think through this carefully. So the problem says that in each step, every psycho who has an id greater than the psycho to their right will kill that right neighbor. But all the ki...
To solve this problem, we need to determine the number of steps required until no psycho in a line kills their right neighbor. Each psycho will kill their right neighbor if their id is greater, and all killings happen simultaneously in each step. The goal is to compute the number of steps needed until no more killings ...
true
63b81adff9e2c491e3b352a5b0635f97
343_B. Alternating Current
Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u...
{"inputs": ["-++-\n", "++\n", "+-\n", "-\n", "+-+--+-+\n", "+-+--+\n", "+-+++-\n", "+++-\n", "-++-+--++--+-++-\n", "-+++--\n", "-+--+-\n", "+-++-+\n", "+++---+++---\n", "+-+-\n", "-+-+-+\n", "+++---\n", "++--++\n", "+---+\n", "--++-+\n", "-+\n", "-+-\n", "--\n", "-+++++\n", "+-+-++\n", "+++\n", "-+-+-+-+-+-+-++-+-+-+-+...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, we need to determine if the given sequence of '+' and '-' characters allows the wires to be untangled. The plus wire starts on top at the left (wall) side, and we need to end up with them not crossing at all. Hmm. So each '+' in the sequence means that the plus wire is ...
To solve this problem, we need to determine if two entangled wires can be untangled such that they run straight from the wall to the device without any crossings. The sequence of crossings is given, and we need to check if it is possible to rearrange the wires to eliminate all crossings. ### Approach The key insight i...
false
Code is incorrect.
d95914d3f745ff2e7d72419690f1661a
366_D. Dima and Trap Graph
Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal... Dima constructed a trap graph. He shouted: "Hey Seryozha, have a look at my cool graph!" to get his roommate inter...
{"inputs": ["4 4\n1 2 1 10\n2 4 3 5\n1 3 1 5\n2 4 2 7\n", "5 6\n1 2 1 10\n2 5 11 20\n1 4 2 5\n1 3 10 11\n3 4 12 10000\n4 5 6 6\n", "5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n", "2 1\n1 2 1 1\n", "1000 0\n", "10 0\n", "6 6\n1 2 1 10\n2 3 1 10\n3 6 1 1\n1 4 1 4\n4 5 1 3\n5 6 ...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about finding a path from node 1 to node n in an undirected graph where each edge has a range [l_k, r_k]. The loyalty of a path is the number of integers x such that x is within all the edges' ranges on the path. We need to find the path with maximum loyalty. If no such path exists or th...
To solve this problem, we need to determine the maximum loyalty of a path from node 1 to node n in an undirected graph where each edge has a range of integers. The loyalty of a path is defined as the number of integers x that can traverse the entire path, which is determined by the intersection of the ranges of all edg...
true
8123e4f811faca01317a28c6beb19454
38_C. Blinds
The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ma...
{"inputs": ["5 3\n5 5 7 3 1\n", "4 2\n1 2 3 4\n", "2 3\n1 2\n", "93 10\n6 47 6 89 21 91 51 72 32 48 54 89 36 12 25 38 58 62 54 16 5 52 52 85 67 33 81 72 6 42 91 16 29 78 56 62 75 48 69 12 89 34 27 15 7 80 14 57 29 6 80 46 64 94 83 96 1 42 11 41 15 26 17 36 44 11 68 73 93 45 73 35 91 14 84 48 7 8 63 84 59 68 87 26 91 10...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. Hmm, so the task is to find the maximum possible area of a window that can be covered using the given blind stripes, considering certain constraints. Let me try to understand the problem step by step. First, the blinds are made by cutting the original stripes into parts, which are then...
To solve this problem, we need to determine the maximum possible area of a window that can be covered using blind stripes, given certain constraints on the lengths of the stripes and the minimum acceptable length of each piece after cutting. ### Approach 1. **Understand the Problem Requirements**: The goal is to find ...
true
6c0b53bc435f909471acfe88aceef5d0
40_B. Repaintings
A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues a...
{"inputs": ["1 1\n1\n", "3 3\n2\n", "3 3\n1\n", "2016 4549\n433\n", "5000 1\n3\n", "4035 369\n26\n", "1595 2881\n710\n", "3762 3914\n1073\n", "4583 2774\n1206\n", "10 10\n1\n", "1812 240\n9\n", "991 2301\n291\n", "3154 527\n112\n", "1353 2988\n589\n", "4999 1\n7\n", "3432 4788\n1203\n", "3990 1800\n171\n", "5000 5000\n...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's going on. The problem is about a chessboard of size n x m. The initial step (minute 0) is to repaint all black squares to color 0. Then, during each i-th minute, some squares are repainted to color i. The condition f...
To solve this problem, we need to determine how many squares on a chessboard are repainted exactly `x` times according to the given repainting rules. The solution involves simulating the repainting process based on the initial chessboard configuration and the specified conditions. ### Approach 1. **Understanding the R...
true
f1b743c598faf60b17470822e998a85e
438_A. The Child and Toy
On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most one rope. To split the toy, the child must remove all its parts. The...
{"inputs": ["4 4\n100 100 100 100\n1 2\n2 3\n2 4\n3 4\n", "4 3\n10 20 30 40\n1 4\n1 2\n2 3\n", "7 10\n40 10 20 10 20 80 40\n1 5\n4 7\n4 5\n5 2\n5 7\n6 4\n1 6\n1 3\n4 3\n1 4\n", "1 0\n23333\n", "3 3\n1 1 1\n1 2\n2 3\n3 1\n", "5 4\n1 2 2 2 2\n1 2\n1 3\n1 4\n1 5\n", "10 30\n3 6 17 15 13 15 6 12 9 1\n3 8\n1 10\n4 7\n1 7\n3...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is to find the minimum total energy the child has to spend to remove all parts of a toy. Each part has a value, and when you remove a part, the cost is the sum of the values of the parts that are still connected to it and haven't been removed yet. So the order of removal matters here. We ne...
To solve this problem, we need to determine the minimum total energy required to remove all parts of a toy, where each part has a value and is connected by ropes. The energy cost to remove a part is the sum of the values of its adjacent parts that have not yet been removed. The goal is to find the optimal order of remo...
true
725a3bb3dae7c7e400ea42067160b85c
45_H. Road Problem
The Berland capital (as you very well know) contains n junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was decided to build several new roads. Every road should connect two junctions. The city administrat...
{"inputs": ["4 4\n1 2\n2 3\n2 4\n3 4\n", "4 3\n1 2\n2 3\n3 4\n", "10 9\n7 9\n8 9\n8 2\n10 6\n8 3\n9 4\n2 6\n8 5\n9 1\n", "2 1\n1 2\n", "20 20\n1 9\n11 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 4\n15 1\n13 16\n11 2\n7 20\n10 15\n3 17\n17 14\n", "20 20\n2 17\n5 17\n14 4\n4 11\n5 1\n4 9\n18 16\n1...
14
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. So the problem is about adding the minimal number of roads to a city's road network such that between any two roads (or any two junctions?), there are at least two paths that don't share any roads. Wait, the problem statement says betwee...
To solve this problem, we need to ensure that the road network of Berland's capital becomes 2-edge-connected. This means that between any two junctions, there should be at least two distinct paths that do not share any roads. The solution involves finding the minimal number of roads to add to achieve this. ### Approac...
false
Code is incorrect.
d1f8e6bb3150e90b1c2574aab490e92e
483_B. Friends and Presents
You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends. In addition, the fir...
{"inputs": ["3 1 2 3\n", "1 3 2 3\n", "1 999999999 29983 29989\n", "9999999 10000 29983 29989\n", "808351 17767 433 509\n", "197 2 6361 18223\n", "5099 2895 16273 29473\n", "500000000 500000000 2 3\n", "1000 9999999 29983 29989\n", "1277613 596606 10427 29387\n", "26941620 135675892 4093 28979\n", "39 154 1033 18947\n"...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, we need to find the minimum number v such that we can assign distinct numbers from 1 to v to two friends. Each friend has certain constraints based on prime divisors. The first friend can't receive numbers divisible by x, the second can't receive divisible by y. And we ha...
To solve this problem, we need to determine the minimum number \( v \) such that we can present distinct positive integers from the set \( \{1, 2, \ldots, v\} \) to two friends under specific constraints. Each friend has a restriction on numbers they can receive based on divisibility by given prime numbers. The goal is...
true
d9b67b7e49ce7822c4f0ea811df6f5a2
507_B. Amr and Pins
Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y'). In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle ...
{"inputs": ["1 1 1 4 4\n", "2 0 0 0 4\n", "4 5 6 5 6\n", "1 100000 100000 100000 -100000\n", "46456 -2621 -23623 -98302 -99305\n", "9 20 0 40 0\n", "100000 -100000 -100000 100000 100000\n", "5 6 3 7 2\n", "97741 23818 78751 97583 26933\n", "99125 26876 -21414 14176 17443\n", "56767 -29030 51625 79823 -56297\n", "125 45...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about moving a circle's center from one point to another using the minimum number of steps. Each step involves pinning a point on the circle's border, rotating around that pin by any angle, which effectively moves the center. I need to find the least number of such steps required. First...
To solve this problem, we need to determine the minimum number of steps required to move the center of a circle from its initial position to a target position. Each step allows the circle to rotate around a point on its border, moving the center by a maximum distance of twice the radius (2r) in a straight line. ### Ap...
true
dcbacff787955b773244dd2f735980ac
556_C. Case of Matryoshkas
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
{"inputs": ["3 2\n2 1 2\n1 3\n", "7 3\n3 1 3 7\n2 2 5\n2 4 6\n", "100 3\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\n29 12 13 14 16 17 20 22 25 26 32 45...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to find the minimum time to assemble all matryoshkas into a single chain from their initial configuration. The operations allowed are either nesting an outer doll into another outer doll, or extracting a doll from its immediate container. Each operation takes one second. Hmm. Let's start by und...
To solve this problem, we need to determine the minimum time required to assemble a single chain of matryoshka dolls from an initial configuration of multiple chains. The operations allowed are nesting a doll into another or extracting a doll from its container, each taking one second. ### Approach 1. **Identify the L...
true
e64f477485afb61bcc0215095284b6f6
582_A. GCD Table
The GCD table G of size n × n for an array of positive integers a of length n is defined by formula <image> Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as <image>. For example, for array a = {4, 3, 6,...
{"inputs": ["4\n2 1 2 3 4 3 2 6 1 1 2 2 1 2 3 2\n", "1\n42\n", "2\n1 1 1 1\n", "3\n121339 121339 121339 55451923 531222142 121339 121339 435485671 121339\n", "3\n1 7 923264237 374288891 7 524125987 1 1 1\n", "5\n2029 6087 2029 2029 6087 2029 527243766 4058 2029 2029 2029 2029 2029 2029 2029 2029 165353355 4058 2029 731...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So, we need to reconstruct the original array a from the GCD table. Hmm. The GCD table is given in a jumbled order, right? So first, I need to understand how the elements of the array relate to the GCD table. Wait, the GCD table G is an n x n matrix where G[i][j] is GCD(a[i], a[j]). Bu...
To solve this problem, we need to reconstruct the original array from a given GCD table. The GCD table is provided as a list of elements in an arbitrary order. The key insight is that the original array elements are the diagonal elements of the GCD table. By leveraging the properties of GCD and using a greedy approach,...
true
830559c71a760496bdb70e0440b18559
604_A. Uncowed Forces
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd a...
{"inputs": ["20 40 60 80 100\n0 1 2 3 4\n1 0\n", "119 119 119 119 119\n0 0 0 0 0\n10 0\n", "36 102 73 101 19\n5 9 2 2 6\n4 13\n", "119 0 0 0 0\n2 0 0 0 0\n5 5\n", "0 0 119 0 0\n0 0 2 0 0\n5 5\n", "0 0 0 0 0\n10 10 10 10 10\n0 20\n", "0 46 86 72 40\n1 5 5 5 9\n6 5\n", "45 45 75 36 76\n6 2 2 0 0\n8 17\n", "119 119 119 11...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's required. The problem is about calculating Kevin's final score in a programming competition based on his submission times, wrong attempts, and hack results. The final score is the sum of the points from each problem ...
To solve this problem, we need to calculate Kevin's final score in a programming competition based on his submission times, wrong attempts, and hack results. The final score is the sum of the points from each problem plus the contributions from successful and unsuccessful hacks. ### Approach 1. **Understanding the Pro...
true
a217dd2226c4c80077b6f06e1c450ffe
626_D. Jerry's Protest
Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry draw randomly without replacement from a jar containing n balls, each labeled with a distinct positive integer. Without looking, they hand their balls to Harry, who awards the point to t...
{"inputs": ["3\n1 2 10\n", "2\n1 2\n", "11\n54 91 4 6 88 23 38 71 77 26 84\n", "20\n11 37 81 56 61 2 26 27 59 69 24 7 71 76 45 54 89 17 95 20\n", "13\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096\n", "11\n1 2 4 8 16 32 64 128 256 512 1024\n", "4\n2 4 1 3\n", "15\n1 2 3 4 5 10 20 40 80 160 320 640 1280 2560 5000\n", "3\n...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is to find the probability that Jerry's sum of three balls is strictly higher than Andrew's, given that Andrew won the first two rounds and Jerry won the third. Hmm. First, I need to model the scenario. Let's break down the problem step by step. So, each round, Andrew and Jerry draw ...
To solve this problem, we need to determine the probability that Jerry's total sum of three drawn balls is strictly higher than Andrew's total sum, given that Andrew wins the first two rounds and Jerry wins the third. ### Approach 1. **Understanding the Problem**: Each round, Andrew and Jerry draw two distinct balls....
true
b0cddbfaed8b7dfc050055643c4bcba1
650_B. Image Preview
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec...
{"inputs": ["5 2 4 13\nhhwhh\n", "3 1 100 10\nwhw\n", "5 2 4 1000\nhhwhh\n", "4 2 3 10\nwwhw\n", "5 2 4 12\nhhhwh\n", "2 5 5 1000000000\nwh\n", "16 1 1000 2100\nhhhwwwhhhwhhhwww\n", "1 2 3 3\nw\n", "10 2 3 32\nhhwwhwhwwh\n", "5 2 4 13\nhhhwh\n", "7 1 1000 13\nhhhhwhh\n", "100 20 100 10202\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhw...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this problem where Vasya wants to watch as many photos as possible within T seconds. The challenge is to figure out the optimal path he should take, considering the time for swiping between photos, rotating them if needed, and the time to view each new photo once. Hmm, the first thing ...
To solve this problem, we need to determine the maximum number of photos Vasya can view within a given time limit, considering the time taken to swipe between photos, rotate them to the correct orientation, and view each photo. The solution involves considering multiple scenarios to find the optimal path for viewing ph...
true
aa8f8fbedaac9bfdeed3487f6eecb498
675_E. Trains and Statistic
Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to ai inclusive. No tickets are sold at the last station. Let ρi, j be the minimum number of tickets one needs to buy in order to get from stations i to station j....
{"inputs": ["4\n4 4 4\n", "5\n2 3 5 5\n", "7\n7 3 4 6 6 7\n", "4\n3 3 4\n", "6\n3 3 6 6 6\n", "5\n4 4 4 5\n", "9\n2 9 7 6 9 7 8 9\n", "3\n3 3\n", "8\n3 7 7 8 8 7 8\n", "10\n2 10 8 7 8 8 10 9 10\n", "2\n2\n", "9\n3 9 7 6 9 7 8 9\n", "4\n3 4 4\n", "8\n3 5 7 8 8 7 8\n", "8\n3 8 7 8 8 7 8\n", "7\n7 3 4 7 6 7\n", "5\n3 3 5 ...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to find the sum of the minimum number of tickets required for all pairs i<j. So for each pair (i,j), compute ρi,j and sum them all up. The input gives the a_i values for each station i (from 1 to n-1), where each a_i is the maximum station you can reach from station i with a single ticket. Hmm...
To solve this problem, we need to compute the sum of the minimum number of tickets required for all pairs of stations (i, j) where 1 ≤ i < j ≤ n. The key insight is to use a greedy approach to determine the minimum number of tickets needed for each pair efficiently. ### Approach 1. **Greedy Jump**: For each station i,...
false
Code is incorrect.
b4d7d13215be5692b79ebe6568ec5716
699_F. Limak and Shooting Points
Bearland is a dangerous place. Limak can’t travel on foot. Instead, he has k magic teleportation stones. Each stone can be used at most once. The i-th stone allows to teleport to a point (axi, ayi). Limak can use stones in any order. There are n monsters in Bearland. The i-th of them stands at (mxi, myi). The given k...
{"inputs": ["3 8\n10 20\n0 0\n20 40\n300 600\n30 60\n170 340\n50 100\n28 56\n90 180\n-4 -8\n-1 -2\n", "2 4\n-2 -1\n4 5\n4 2\n2 1\n4 -1\n1 -1\n", "1 10\n778084 -205153\n778001 -205093\n778155 -205118\n778168 -204997\n778066 -205141\n778146 -205036\n778041 -205063\n778012 -204996\n778132 -205128\n778049 -205131\n778049 -...
12
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out this problem. So the task is to determine how many monsters are afraid of Limak. A monster is afraid if there's a way for Limak to teleport using his stones and then shoot an arrow in a direction that hits that monster first. Hmm. So the key here is, for each monster, we need to check if...
To solve this problem, we need to determine how many monsters in Bearland should be afraid of Limak, given that he can use up to 7 magic teleportation stones. Each stone allows Limak to teleport to a specific point, from where he can shoot an arrow in a specific direction, hitting the first monster in that direction. T...
false
Code is incorrect.
912dcea5533b0a415cc99a2402272e66
720_C. Homework
Today Peter has got an additional homework for tomorrow. The teacher has given three integers to him: n, m and k, and asked him to mark one or more squares on a square grid of size n × m. The marked squares must form a connected figure, and there must be exactly k triples of marked squares that form an L-shaped tromi...
{"inputs": ["3\n3 3 4\n3 3 5\n3 3 3\n", "1\n317 314 18260\n", "1\n315 315 355287\n", "1\n316 314 143218\n", "1\n516 6 6571\n", "1\n317 315 396613\n", "1\n18 5 158\n", "1\n315 316 124373\n", "1\n315 317 46432\n", "1\n314 317 33011\n", "1\n316 316 153829\n", "1\n314 315 29709\n", "1\n315 314 148940\n", "1\n314 314 191131...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is to generate a grid of size n x m where certain squares are marked such that the marked squares form a connected figure. Also, there must be exactly k L-shaped tromino triples. Hmm, what's an L-shaped tromino? Oh right, three squares forming a 2x2 square minus one corner. So in any 2x2 bl...
To solve this problem, we need to generate a grid of size n x m where the marked squares form a connected figure and there are exactly k L-shaped trominoes. An L-shaped tromino is defined as three squares forming a corner of a 2x2 square. ### Approach 1. **Understanding L-shaped Trominoes**: Each 2x2 square can contri...
false
Code is incorrect.
da96c14862fff76178ce3713f2e27f1e
741_E. Arpa’s abnormal DNA and Mehrdad’s deep interest
All of us know that girls in Arpa’s land are... ok, you’ve got the idea :D Anyone knows that Arpa isn't a normal man, he is ... well, sorry, I can't explain it more. Mehrdad is interested about the reason, so he asked Sipa, one of the best biology scientists in Arpa's land, for help. Sipa has a DNA editor. <image> S...
{"inputs": ["abbbbbbaaa baababaaab 10\n1 2 1 0 0\n2 7 8 4 7\n2 3 9 2 8\n3 4 6 1 1\n0 8 5 2 4\n2 8 10 4 7\n7 10 1 0 0\n1 4 6 0 2\n0 9 8 0 6\n4 8 5 0 1\n", "abc d 4\n0 3 2 0 0\n0 3 1 0 0\n1 2 1 0 0\n0 1 3 2 2\n", "xkbvkadjec gqjlhxpnsx 10\n2 7 1 0 0\n2 5 8 0 0\n4 7 8 0 4\n0 4 7 3 6\n5 5 9 3 7\n7 9 5 0 3\n6 8 6 4 4\n5 7 6...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about DNA strings and selecting the best insertion point for T into S. For each query, we have to find the optimal i in a certain range [l, r] that satisfies i mod k is between x and y inclusive. Among those i...
To solve this problem, we need to determine the optimal position to insert a DNA string T into another DNA string S such that the resulting string is lexicographically smallest. The solution must efficiently handle multiple queries with constraints on the insertion positions. ### Approach 1. **Preprocessing with Z-Alg...
false
Code is incorrect.
73386d0f5cd2e2cb31c1c1f1da3deb72
765_D. Artsem and Saunders
Artsem has a friend Saunders from University of Chicago. Saunders presented him with the following problem. Let [n] denote the set {1, ..., n}. We will also write f: [x] → [y] when a function f is defined in integer points 1, ..., x, and all its values are integers from 1 to y. Now then, you are given a function f: [...
{"inputs": ["3\n1 2 3\n", "3\n2 2 2\n", "2\n2 1\n", "3\n2 2 3\n", "5\n1 4 5 4 5\n", "4\n2 2 4 4\n", "3\n1 1 2\n", "4\n1 2 1 2\n", "4\n4 2 2 4\n", "6\n1 2 3 4 5 5\n", "1\n1\n", "10\n4 4 4 4 4 4 4 4 4 4\n", "7\n7 3 3 5 5 7 7\n", "5\n1 2 3 4 3\n", "4\n1 2 1 1\n", "4\n4 2 4 4\n", "6\n1 1 1 4 4 4\n", "2\n1 2\n", "4\n3 4 3 4...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. So, the problem is about finding two functions g and h that satisfy certain conditions based on the given function f. Hmm. Let me start by understanding the requirements. The problem states that for all x in [m], g(h(x)) should equal x. That sounds like h is a r...
To solve this problem, we need to determine if we can decompose a given function \( f \) into two functions \( g \) and \( h \) such that specific composition properties are satisfied. If such a decomposition is possible, we must construct the functions; otherwise, we should indicate it's impossible. ### Approach 1. *...
false
Code is incorrect.
f4a2ecb83cf8d44fda519af5cbbaefaf
789_A. Anastasia and pebbles
Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park. She has only two pockets. She can put at most k pebbles in each pocket at the same time....
{"inputs": ["5 4\n3 1 8 9 7\n", "3 2\n2 3 4\n", "10 1\n1 1 1 1 1 1 1 1 1 1\n", "3 57\n78 165 54\n", "1 1\n10000\n", "2 2\n2 2\n", "9 13\n132 87 200 62 168 51 185 192 118\n", "5 72\n74 10 146 189 184\n", "1 22\n1\n", "10 1\n1 0 1 1 1 1 1 1 1 1\n", "3 87\n78 165 54\n", "9 13\n132 166 200 62 168 51 185 192 118\n", "5 72\n...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about Anastasia collecting pebbles into her two pockets. Each pocket can hold at most k pebbles, and each pocket can't mix different types. So for each type of pebble, she has to figure out how many pockets she needs per day, and then distribute those across days, possibly using both poc...
To solve this problem, we need to determine the minimum number of days Anastasia needs to collect all pebbles from the park using her two pockets, given that each pocket can hold at most `k` pebbles of the same type. ### Approach 1. **Understanding Pocket Usage**: Each pocket can hold up to `k` pebbles of a single typ...
true
49d5bd2bcfc8607c824507883eb03d22
80_C. Heroes
The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us...
{"inputs": ["3\nTroll likes Dracul\nDracul likes Anka\nSnowy likes Hexadecimal\n210 200 180\n", "2\nAnka likes Chapay\nChapay likes Anka\n10000 50 50\n", "0\n2000000000 2000000000 1\n", "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this programming problem. Hmm. The problem is about splitting seven heroes into three teams to fight three bosses. Each team's experience is calculated as the boss's experience divided by the team size, rounded down. The goal is to find the minimal possible difference between the maximu...
To solve this problem, we need to split seven heroes into three teams to fight three megabosses such that the difference between the maximum and minimum experience points any hero receives is minimized. Additionally, among all possible splits that achieve this minimal difference, we need to maximize the total amount of...
true
a04f8a4312cf1039bf94939f04dbaec7
835_A. Key races
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 millis...
{"inputs": ["4 5 3 1 5\n", "5 1 2 1 2\n", "3 3 1 1 1\n", "2 313 856 964 421\n", "61 464 623 89 548\n", "37 261 207 1 1000\n", "4 202 512 995 375\n", "3 3 1 6 9\n", "213 480 811 134 745\n", "1 10 2 6 10\n", "6 5 7 10 4\n", "2 7 6 2 3\n", "29 344 406 900 1\n", "1 2 8 8 5\n", "1 1 1 1 1\n", "424 41 41 909 909\n", "641 31 ...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about two participants in a typing competition, and we need to determine who wins based on their typing speeds and pings. Hmm. So, the input is s, v1, v2, t1, t2. The output depends on which participant's total time is less. But wait, how exactly do we calculate the total time for each ...
To solve this problem, we need to determine the winner of a typing competition between two participants based on their typing speeds and connection pings. The winner is the participant whose success information arrives first at the server. If both participants' information arrives simultaneously, the result is a draw. ...
true
37113893932f9913935f0ef688fd303c
855_D. Rowena Ravenclaw's Diadem
Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her. Harry thought that Riddle would have assumed that he was the only one to discover the Room of Requirement and thus, would have hidden it there. So Harry ...
{"inputs": ["3\n-1 -1\n1 0\n2 0\n2\n1 1 3\n2 1 3\n", "3\n-1 -1\n1 0\n1 1\n2\n2 2 3\n2 3 2\n", "20\n-1 -1\n1 0\n2 0\n2 1\n2 1\n4 0\n1 0\n4 0\n3 0\n9 0\n6 1\n3 1\n11 1\n2 0\n2 1\n8 1\n14 1\n5 1\n15 0\n18 1\n20\n1 11 11\n2 6 8\n1 13 13\n2 3 4\n2 3 7\n2 14 5\n2 5 4\n1 7 7\n2 10 15\n2 3 5\n1 16 16\n1 20 20\n2 3 4\n1 10 10\n...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. Hmm, the problem is about determining certain relationships between objects based on their parent relations and types. We need to answer queries about whether one object is a special case of another or a part of another. First, I need to understand the relations...
To solve this problem, we need to determine if one object is a special case or a part of another based on a hierarchical structure. The solution involves efficiently navigating and querying two types of hierarchies: one for special cases (type 0) and another for parts (type 1). ### Approach 1. **Hierarchy Representati...
false
Code is incorrect.
3c6cba5f9e3b514b6b742c8f3356756b
87_B. Vasya and Types
Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the language's description below...
{"inputs": ["17\ntypedef void* b\ntypedef b* c\ntypeof b\ntypeof c\ntypedef &amp;b b\ntypeof b\ntypeof c\ntypedef &amp;&amp;b* c\ntypeof c\ntypedef &amp;b* c\ntypeof c\ntypedef &amp;void b\ntypeof b\ntypedef b******* c\ntypeof c\ntypedef &amp;&amp;b* c\ntypeof c\n", "5\ntypedef void* ptv\ntypeof ptv\ntypedef &amp;&amp;...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. Hmm, the description is a bit complex, but let's break it down step by step. So, the problem is about simulating the typedef and typeof operations in this fictional language. The key points are how the pointer and dereference operations work, especially with the errtype and void. Also...
To solve this problem, we need to simulate the behavior of the `typedef` and `typeof` operators in the fictional &K* programming language. The challenge lies in correctly resolving type definitions and handling pointer and dereference operations according to the specified rules. ### Approach 1. **Type Definition (type...
false
Code is incorrect.
814aa770f9a818c1f1f37782912b4dc7
903_D. Almost Difference
Let's denote a function <image> You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n. Input The first line contains one integer n (1 ≤ n ≤ 200000) — the number of elements in a. The second line contains n integers a1, a2, ..., ...
{"inputs": ["4\n6 6 5 5\n", "5\n1 2 3 1 3\n", "4\n6 6 4 4\n", "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 ...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this programming problem where I have to calculate the sum of d(ai, aj) for all pairs i ≤ j. The function d is defined as (ai - aj) if i < j, and 0 if i = j. Wait, no, wait. The image shows that d(ai, aj) is (ai - aj) if i < j, and 0 when i = j. So for all pairs where i is less than j, ...
To solve this problem, we need to calculate the sum of the function d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n. The function d(ai, aj) is defined based on specific conditions that need to be derived from the examples provided. ### Approach Upon analyzing the examples, it becomes evident that the function ...
false
Code is incorrect.
e1de0893198ccacd3e041f70c023a06a
925_E. May Holidays
It's May in Flatland, and there are m days in this month. Despite the fact that May Holidays are canceled long time ago, employees of some software company still have a habit of taking short or long vacations in May. Of course, not all managers of the company like this. There are n employees in the company that form a...
{"inputs": ["5 6\n1 2 3 4\n4 0 0 1 0\n1 5 2 3 -5 -1\n", "7 8\n4 5 1 1 5 5\n0 0 0 1 2 0 0\n2 6 3 7 -2 4 -3 1\n", "10 10\n5 9 1 3 5 8 3 4 7\n2 0 4 7 1 0 0 0 7 0\n5 7 -7 3 10 4 7 2 9 -9\n", "2 2\n1\n0 0\n1 2\n", "2 2\n1\n0 0\n2 -2\n", "10 10\n1 1 3 6 1 2 3 3 6\n3 0 2 0 0 0 0 0 0 0\n7 9 4 -9 6 -6 2 -7 7 10\n", "2 2\n1\n0 0...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's required. So, the problem is about employees in a company structured as a tree. Each employee has a certain number of subordinates, and each has a bearing limit t_i. If more than t_i of their subordinates are on vaca...
To solve this problem, we need to track the number of displeased employees in a company structured as a tree after each day's event where an employee either goes on vacation or returns from one. An employee becomes displeased if the number of their subordinates on vacation exceeds their bearing limit while they are not...
true
2adcfcaa077e85f20a909bb2183bb989
954_F. Runner's Problem
You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column. You start in (2, 1) and have to end your path in (2, m). From the cell (i, j) you may advance to: * (i - 1, j + 1) — only if i > 1, * (i, ...
{"inputs": ["2 5\n1 3 4\n2 2 3\n", "50 100\n1 71 96\n2 34 52\n2 16 95\n1 54 55\n1 65 85\n1 76 92\n2 19 91\n1 26 43\n2 83 95\n2 70 88\n2 67 88\n1 9 75\n2 4 50\n2 9 11\n1 77 92\n1 28 58\n1 23 72\n1 24 75\n2 12 50\n1 54 55\n2 45 93\n1 88 93\n2 98 99\n1 40 58\n2 40 42\n1 16 61\n2 94 94\n1 82 86\n2 81 85\n2 46 46\n2 88 97\n...
12
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. Hmm. So the problem is about counting the number of paths from (2,1) to (2,m) in a 3xM grid, avoiding certain obstacles. The movement is such that from any cell (i,j), you can move to three possible cells in the next column: up, same row, or down, as long as you ...
To solve this problem, we need to count the number of valid paths from the starting position (2, 1) to the ending position (2, m) in a 3xM grid, avoiding blocked cells. The solution must efficiently handle large values of M (up to 10^18) using matrix exponentiation and interval processing. ### Approach 1. **Input Hand...
true
7a87d4bd89214bc17cf87c0d7760b71f
980_E. The Number Games
The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant. The nation has n districts numbered from 1 to n, each district has exactly one path connecting it to every other district. The number of fans of a contestant from district i is equ...
{"inputs": ["6 3\n2 1\n2 6\n4 2\n5 6\n2 3\n", "8 4\n2 6\n2 7\n7 8\n1 2\n3 1\n2 4\n7 5\n", "64 63\n11 51\n64 11\n64 39\n11 6\n24 64\n51 63\n43 51\n64 29\n6 22\n47 6\n1 47\n41 22\n41 38\n4 47\n35 47\n41 23\n45 1\n52 35\n26 45\n15 35\n21 35\n23 32\n12 21\n21 62\n25 21\n28 25\n15 54\n57 12\n20 28\n48 57\n8 57\n20 44\n46 28...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out this problem. So the problem is about a tree structure where each district is a node. The president wants to remove k districts such that the remaining districts form a connected component. The goal is to maximize the sum of 2^i for all remaining districts. We need to find which k district...
To solve this problem, we need to determine which districts (contestants) to remove such that the remaining districts form a connected component with the maximum possible sum of fans. The sum of fans is dominated by higher-numbered districts due to the exponential growth of 2^i. The solution involves selecting the larg...
false
Code is incorrect.
059042f7dd8d7b9d8c662c33742c414c
9_E. Interesting Graph and Apples
Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to any other cycles. A f...
{"inputs": ["3 2\n1 2\n2 3\n", "42 28\n7 19\n15 24\n3 42\n18 5\n32 27\n26 20\n40 30\n35 2\n14 8\n22 10\n36 4\n16 14\n21 29\n37 40\n2 12\n30 21\n19 17\n39 34\n31 28\n20 3\n4 33\n11 42\n26 21\n9 10\n4 32\n6 1\n1 14\n14 12\n", "2 2\n1 2\n2 1\n", "3 2\n3 2\n2 1\n", "3 3\n1 3\n2 1\n3 2\n", "2 3\n1 1\n1 2\n2 1\n", "50 27\n10...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. The problem is about determining if we can add edges to a given undirected graph to make it an "interesting graph" as defined, with the minimal number of added edges and lexicographically smallest solution if possible. First, let's understand what an interesting...
To solve this problem, we need to determine if we can transform an undirected graph into an "interesting graph" by adding the minimal number of edges. An interesting graph is defined as one where each vertex belongs to exactly one cycle (a funny ring), which can be a simple cycle or a loop. Additionally, the solution m...
false
Code is incorrect.
0571f5aa98cc1231bb591e405ba9aaa1
bhavanas-and-bhuvanas-bet
Bhavana and Bhuvana place bet every time they see something interesting that can occur with a probability 0.5. Both of them place a bet for a higher amount which they don’t posses at that time. But when one wins she demands other for the bet amount. For example if Bhuvana wins she asks bhavana for the bet amount. But...
{"inputs": ["2\n3\n10"], "outputs": ["1\n3"]}
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's see. The problem is about finding the minimum number of cuts Bhavana needs to make on her chocolate bar so that she can use the pieces to pay Bhuvana over N days. The goal is to minimize the number of cuts. Hmm, the sample input helps. For example, when N is 3, she makes one cut, resulting in two pieces: ...
To solve this problem, we need to determine the minimum number of cuts Bhavana needs to make on her chocolate bar so that she can use the pieces to pay Bhuvana over N days. The goal is to minimize the number of cuts while ensuring each number from 1 to N can be formed as a sum of the pieces. ### Approach 1. **Problem ...
true
5fa14da6b32349f1b335936cbe2aa4cd
cost-of-data-11
Strings can be efficiently stored as a data structure, to have efficient searching methods. A new startup is going to use this method, but they don't have much space. So they want to check beforehand how much memory will be required for their data. Following method describes the way in which this startup's engineers s...
{"inputs": ["5\net\neq\nbd\nbe\nbdp\n\nSAMPLE", "5\neu\neq\nbd\nbe\nbdp\n\nSAMPLE", "5\neu\neq\nbd\nbe\ndbp\n\nSAMQLE", "5\neu\neq\nbd\nbd\ndbp\n\nSAMQLE", "5\net\nqe\nbd\ndc\ndbp\n\nSAMQLE", "5\nte\nqe\nbd\ndb\np`d\n\nDAQMKS", "5\neu\neq\nbd\nbe\nbdp\n\nELPMAS", "5\neu\neq\nbd\nbe\nbdp\n\nSAMQLE", "5\neu\nqe\nbd\nbd\n...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's see. The problem is about determining the number of nodes used in a certain data structure when inserting a bunch of strings. The sample input shows that inserting those 5 words results in 8 nodes. The structure looks a lot like a trie. Oh right, because a trie is a tree where each node represents a charact...
To solve this problem, we need to determine the number of nodes used in a trie data structure when inserting a list of strings. Each node in the trie represents a character, and each path from the root to a node represents a prefix of at least one string in the list. The goal is to count the total number of nodes creat...
false
Code is incorrect.
42a10cb888f1bfdf72adccca13f7e11f
find-the-nth-prime
Given the value of n, print the n'th prime number. Input : A single integer n. Output : A single number which is the n'th prime number. Constraints : 1 ≤ n ≤ 1000 SAMPLE INPUT 2 SAMPLE OUTPUT 3 Explanation The first few prime numbers are: 2,3,5,7. So, the answer is 3.
{"inputs": ["2\n\nSAMPLE", "2\n\nSBMPLE", "2\n\nSBPMLE", "2\n\nELMPBS", "2\n\nELMPAS", "2\n\nSAPMLE", "2\n\nSAQMLE", "2\n\nELMQAS", "2\n\nELMQBS", "2\n\nELLQBS", "2\n\nEMLQBS", "2\n\nEMLQBT", "2\n\nTBQLME", "2\n\nTCQLME", "2\n\nSCQLME", "2\n\nTCQKME", "2\n\nEMKQCT", "2\n\nCMKQET", "2\n\nBMKQET", "2\n\nCMKQTE", "2\n\nCM...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to generate a Python function that takes an integer n as input and outputs the nth prime number. Let's think about how to approach this. First, I remember that prime numbers start from 2, which is the first prime. Then 3, 5, 7, etc. So for n=2, the output is 3 as in the sample. Got it. The problem is to ...
To solve this problem, we need to determine the n-th prime number. Prime numbers are integers greater than 1 that have no divisors other than 1 and themselves. The challenge is to efficiently generate prime numbers until we reach the n-th one. ### Approach 1. **Initialization**: Start with the first prime number, whic...
true
1ce153405b603328ef38ac29718802f0
insect-colony-2
Yesterday Oz heard a story about insect colony. The specialty of insects is that they splits sometimes i.e an insect of size A can split into two insects of positive integral sizes B and C such that A = B + C. Also sometimes they attack each other i.e. two insects of sizes P and Q will become R = P XOR Q . You are give...
{"inputs": ["2\n2 9 17\n1 1\n\nSAMPLE", "10\n75 995991040 148627929 566366239 458028006 823890903 945174886 530827147 546010999 720763988 183796976 748924885 868038355 870234651 273702889 972313979 607688156 495203509 981301128 72001489 10285302 970980434 30653173 738175457 455018413 940530064 537884091 418532701 98235...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's try to figure out this problem. The question is whether a given set of insect sizes can be reduced to zero through a series of splits and attacks. Let me think about the operations allowed here. So, the operations are split and attack. Let's break them down: 1. Split: An insect of size A can split into B ...
To solve this problem, we need to determine if an insect colony can be completely eliminated through a series of splits and attacks. The key insight is to leverage the properties of the sum and XOR operations to derive a solution. ### Approach 1. **Sum Parity Check**: The sum of the sizes of the insects must be even. ...
true
159e1c4c5db4a80885cc00f63a3334db
max-min
you are given an array of size N. You need to select K elements from the array such that the difference between the max number among selected and the min number among selected array elements should be minimum. Print the minimum difference. INPUT: First line N number i.e., length of array Second line K number Next N l...
{"inputs": ["5\n3\n1\n2\n3\n4\n5\n\nSAMPLE", "5\n3\n1\n1\n3\n4\n5\n\nSAMPLE", "5\n3\n1\n3\n3\n4\n5\n\nSAMPLE", "5\n4\n1\n1\n3\n5\n5\n\nSAMPLE", "5\n1\n0\n3\n3\n4\n5\n\nQAMRLD", "5\n3\n0\n6\n3\n4\n9\n\nLMRDAQ", "5\n3\n1\n1\n3\n5\n5\n\nSAMPLE", "5\n3\n1\n2\n3\n4\n7\n\nSAMPLE", "5\n3\n1\n3\n3\n4\n5\n\nPAMSLE", "5\n3\n1\n3...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, so I need to solve this problem where I have to select K elements from an array such that the difference between the maximum and minimum in the selected elements is as small as possible. The goal is to find the minimum possible difference. Let's think about how to approach this. First, let's look at the sample i...
To solve this problem, we need to select K elements from an array such that the difference between the maximum and minimum values in the selected elements is minimized. The optimal approach involves sorting the array and then examining consecutive windows of K elements to find the minimum possible difference. ### Appr...
true
fc6e36bb433ffec9d45165d05d26d47a
once-upon-a-time-in-time-land
In a mystical TimeLand, a person's health and wealth is measured in terms of time(seconds) left. Suppose a person there has 24x60x60 = 86400 seconds left, then he would live for another 1 day. A person dies when his time left becomes 0. Some time-amount can be borrowed from other person, or time-banks. Some time-amoun...
{"inputs": ["2\n10 1\n1 2 -3 -5 4 6 -3 2 -1 2\n10 2\n1 2 -3 -5 4 6 -3 2 -1 2\n\nSAMPLE", "30\n16 3\n-334 -500 -169 -724 -478 -358 -962 -464 -705 -145 -281 -827 -961 -491 -995 -942 \n22 2\n391 604 902 153 292 382 421 716 718 895 447 726 771 538 869 912 667 299 35 894 703 811 \n17 5\n-673 141 -253 -547 662 -37 723 -529 3...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's tackle this problem. So, the task is to find the maximum possible sum by selecting elements from an array with the restriction that if we pick an element at index i, the next one has to be at least i+K+1. Hmm. Wait, the problem statement says that the indices have to be at least K apart. Wait, the restricti...
To solve this problem, we need to determine the maximum possible sum of time-amounts that can be collected from slips under the restriction that each selected slip must be at least K indices apart from the previous one. The solution should be efficient enough to handle the upper constraints of the problem. ### Approac...
true
10075807c38ff83cb323f23e40de711d
rams-love-for-sita-2
Sita loves chocolate and Ram being his boyfriend wants to give Sita as many chocolates as he can. So, he goes to a chocolate store with Rs. N in his pocket. The price of each chocolate is Rs. C. The store offers a discount that for every M wrappers he gives to the store, he gets one chocolate for free. How many chocola...
{"inputs": ["3\n10 2 5\n12 4 4\n6 2 2\n\nSAMPLE", "3\n10 2 5\n12 4 8\n6 2 2\n\nSAMPLE", "3\n7 2 5\n12 4 8\n6 2 2\n\nSAMPLF", "3\n7 2 5\n12 4 8\n6 2 4\n\nSAMPLF", "3\n12 2 5\n12 4 8\n6 2 4\n\nSAMPLF", "3\n12 2 5\n2 4 16\n6 2 4\n\nSAMPLF", "3\n12 2 5\n4 4 16\n6 2 4\n\nSAMPLF", "3\n12 2 5\n8 4 16\n6 2 4\n\nSAMPLF", "3\n12...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to solve this problem where Ram buys chocolates with his money and then exchanges wrappers for more chocolates based on a discount. Let's think through the steps. First, the problem says that for each test case, we have N (money), C (cost per chocolate), and M (wrappers needed for a free one). The goal is...
To solve this problem, we need to determine the maximum number of chocolates Ram can buy with his money and take advantage of a discount where he can exchange wrappers for additional chocolates. The solution involves both initial purchases and iterative exchanges of wrappers. ### Approach 1. **Initial Purchase**: Calc...
true
f13601a109f8350f6ec1e72d1b50db94
simple-prime-factorization
Surya loves to play with primes. One day, he asked his friend don to print any number in the form of multiple of prime factors. Help don in solving the problem. Input The first line will contain an integer t (1 ≤ t ≤ 10^6) denoting number of test case. For each test case, you will be given an integer n (2 ≤ n ≤ 10^6...
{"inputs": ["3\n32\n100\n9085\n\nSAMPLE", "1000\n999001\n999002\n999003\n999004\n999005\n999006\n999007\n999008\n999009\n999010\n999011\n999012\n999013\n999014\n999015\n999016\n999017\n999018\n999019\n999020\n999021\n999022\n999023\n999024\n999025\n999026\n999027\n999028\n999029\n999030\n999031\n999032\n999033\n999034\...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's see. The problem is to print the prime factors of a number n in a specific format. The output needs to list the prime factors starting with 2, followed by others in order, each with their exponents. But wait, the note says that even if 2 isn't a factor, we have to include 2^0. Oh right, like for a prime num...
To solve this problem, we need to generate the prime factorization of a given number in a specific format. The output must always include the power of 2, even if it's zero, and for prime numbers, only the term 2^0 should be printed. ### Approach 1. **Precompute Smallest Prime Factors (SPF):** Using a sieve algorithm, ...
false
Code is incorrect.
38fc1a3262829486d91577d287821420
the-strongest-string-1-1
Maga and Alex are good at string manipulation problems. Just now they have faced a problem related to string. But it is not a standard string problem. They have no idea to solve it. They need your help. A string is called unique if all characters of string are distinct. String s_1 is called subsequence of string s_2 ...
{"inputs": ["5\nabvzx\n\nSAMPLE", "5\nabvzx\n\nSAMOLE", "5\nxbvza\n\nSAMOLE", "5\nxbvya\n\nSAMOLE", "5\nabvxz\n\nSAMOLE", "5\nayvbx\n\nSAMOLE", "5\nzavbw\n\nSAMOLE", "5\nazwaw\n\nSOMALF", "5\nbywaw\n\nSOMALF", "5\nwawyb\n\nSOMALG", "5\nxywab\n\nDTALON", "5\nxw`xb\n\nSOMALE", "5\nb`wyy\n\nCTAMON", "5\nxzvaa\n\nBKNNER", ...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's try to figure out this problem. So the task is to find the strongest unique string which is a subsequence of the given string. The strongest here means lexicographically greatest, and unique means all characters are distinct. Hmm. First, I need to understand what exactly is required. The output should be t...
To solve this problem, we need to find the lexicographically greatest unique subsequence of a given string. A unique subsequence is one where all characters are distinct and appear in the same order as they do in the original string. ### Approach 1. **Preprocess Occurrences**: For each character in the string, record ...
true
2713f04b18fed5a27508c50e26a6bbe6
p02548 AtCoder Beginner Contest 179 - A x B + C
Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? Constraints * 2 \leq N \leq 10^6 * All values in input are integers. Input Input is given from Standard Input in the following format: N Output Print the answer. Examples Input 3 Output 3 Input 100 ...
{"inputs": ["3", "100", "1000000", "4", "101", "5", "001", "8", "6", "2", "110", "10", "13", "111", "12", "17", "9", "7", "14", "16", "11", "22", "26", "18", "19", "24", "43", "23", "44", "72", "32", "20", "15", "33", "27", "65", "42", "54", "31", "25", "59", "37", "107", "71", "183", "74", "113", "90", "29", "21", "28...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. I need to find the number of tuples (A, B, C) of positive integers that satisfy A × B + C = N. Hmm, right. So the problem is, given N, count all possible triples where when you multiply A and B and add C, you get N. First, let's understand the equation: A * B + C = N. Since all variables are positive...
To solve this problem, we need to determine the number of tuples (A, B, C) of positive integers that satisfy the equation A × B + C = N for a given positive integer N. ### Approach The key insight is that for each valid pair (A, B), there exists exactly one positive integer C such that C = N - A × B. Therefore, the p...
true
9909710829cc8d56f7b0ea5e735466df
p02679 AtCoder Beginner Contest 168 - ∙ (Bullet)
We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and o...
{"inputs": ["3\n1 2\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4", "3\n1 4\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -6\n-8 12\n7 7\n8 1\n8 2\n8 4", "3\n2 4\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -6\n-8 12\n7 1\n8 1\n8 2\n8 4", "3\n2 4\n-2 1\n2 -1", "10\n3 2\n3 0\n-1 1\n2 -1\n-3 -6\n...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I have to solve this problem where I need to count the number of valid subsets of sardines such that no two are on bad terms. The condition for being on bad terms is that their A_i*A_j + B_i*B_j equals zero. The answer needs to be modulo 1e9+7. Let's think about this step by step. First, I need to understand the...
To solve this problem, we need to determine the number of valid subsets of sardines such that no two sardines in a subset are on bad terms. Sardines are on bad terms if their vectors are perpendicular. The solution involves grouping vectors into normalized directions and handling each group's contribution to the total ...
true
86529836c89c8cd486f638c12995639a
p02807 Dwango Programming Contest 6th - Fusing Slimes
There are N slimes standing on a number line. The i-th slime from the left is at position x_i. It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}. Niwango will perform N-1 operations. The i-th operation consists of the following procedures: * Choose an integer k between 1 and N-i (inclusive) with equ...
{"inputs": ["12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932", "3\n1 2 3", "12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086", "3\n1 2 5", "12\n161735902 394362112 4303...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's tackle this programming problem. Hmm, the problem seems a bit tricky, but I'll try to break it down step by step. So, the problem is about slimes on a number line. Each time, we choose the k-th slime from the left (k is random between 1 and N-i+1, maybe?), move it to the right neighbor, and fuse them. We h...
To solve this problem, we need to determine the total distance traveled by slimes during a series of merge operations, multiplied by (N-1)!, and then take the result modulo \(10^9 + 7\). The key insight is to recognize that each interval between consecutive slimes contributes to the total distance based on the number o...
false
Code is incorrect.
307e6c73cbb492e20c731fb2cb3f4855
p02943 AtCoder Grand Contest 037 - Reversing and Concatenating
Takahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times: * Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. * Let S' be some contiguous substring of U with length N, an...
{"inputs": ["5 1\nbacba", "10 2\nbbaabbbaab", "5 2\nbacba", "10 2\nbbbabbbaaa", "10 3\nbbaabbbaab", "5 2\nbacaa", "10 2\nbaabbbaabb", "10 2\nbaabbaaabb", "10 2\nbbaaabbbab", "5 1\nbabba", "10 2\nbabbbbaabb", "10 1\nbaabbaaabb", "5 1\nbabbb", "10 2\nbbaabbbbab", "10 1\nbbaaabbaab", "8 5\nbbaaabbbab", "5 1\nbabbc", "5 2\...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So the problem is: Takahashi has a string S of length N. He performs K operations. Each operation is as follows: 1. Reverse S to get T. 2. Concatenate S and T to form U (so U is S followed by T). 3. Select a contiguous substri...
To solve this problem, we need to find the lexicographically smallest possible string after performing K operations on an initial string S. Each operation involves reversing the string, concatenating it with the original, and selecting the smallest contiguous substring of length N from the concatenated result. ### Ap...
false
Code is incorrect.
3400d4e733ea455f17f84a6a32d8b504
p03080 ExaWizards 2019 - Red or Blue
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. Constraints * 1 \l...
{"inputs": ["4\nRRBR", "4\nBRBR", "4\nRBRR", "4\nBBRR", "4\nRRCR", "4\nRRAR", "4\nRARR", "4\nBQBR", "4\nRCRR", "4\nBPBR", "4\nRRRC", "4\nAQBR", "4\nRRRD", "4\nAQBS", "4\nDRRR", "4\nARBS", "4\nERRR", "4\nBQBS", "4\nBPBS", "4\nPBBS", "4\nSBBP", "4\nPBSB", "4\nPASB", "4\nPASC", "4\nPACS", "4\nPCAS", "4\nCPAS", "4\nCOAS", ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to determine if there are more red hats than blue hats in a group of people. So, given a string s where each character is either 'R' or 'B', I need to count how many Rs and Bs there are. Then, compare the counts. If the count of R is greater than B, output Yes, else No. Hmm. So the step...
To solve this problem, we need to determine if there are more people wearing red hats than blue hats based on a given string of hat colors. ### Approach 1. **Input Reading**: Read the integer `N` which represents the number of people, and the string `s` which represents the colors of the hats each person is wearing. 2...
true
d0756bf24007d2d1c2da98d184ba713f
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
{"inputs": ["5 4\n#.##\n.##.\n#...\n..##\n...#", "13 27\n......#.........#.......#..\n...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n.#.#.#...###..\n...........#...#...#######\n..#######..#...#...#.....#\n....
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to count the number of triples of coins such that all pairs in the triple have the same Manhattan distance. Hmm. Wait, wait. The condition is that choosing any two of the three coins results in the same Manhattan distance. So all three pairs must have the same Manhattan distance. So for ...
To solve this problem, we need to count the number of triples of coins such that the Manhattan distance between any two coins in the triple is the same. The Manhattan distance between two points (x1, y1) and (x2, y2) is given by |x1 - x2| + |y1 - y2|. ### Approach 1. **Collect Coin Positions**: First, we read the grid...
false
Code is incorrect.
05f6cb8840e3fa19db7f521b5e4eaff0
p03371 AtCoder Beginner Contest 095 - Half and Half
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
{"inputs": ["1500 2000 1600 3 2", "1500 2000 500 90000 100000", "1500 2000 1900 3 2", "1500 1572 1600 3 2", "1500 2445 500 90000 100000", "1500 2000 1615 3 2", "1500 1572 1600 0 2", "1500 2000 1166 3 2", "1500 651 1600 0 2", "1500 3132 752 90000 100000", "1500 2000 1343 3 2", "1500 2000 1343 3 3", "1339 651 1600 0 1", ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I need to solve this problem where I have to find the minimum cost to get X A-pizzas and Y B-pizzas. The options are buying A, B, or AB pizzas. But AB can be split into half A and half B. Hmm, right. So the main idea is that for each AB pizza, when you split it, you get 0.5 A and 0.5 B. But since we need whole p...
To solve this problem, we need to determine the minimum cost to prepare the required number of A-pizzas and B-pizzas using a combination of purchasing A-pizzas, B-pizzas, and AB-pizzas. The key is to leverage the cost efficiency of AB-pizzas where possible, as they can be rearranged into A and B-pizzas when bought in p...
true
d6cbe312c420d5d0a558605639d83406
p03534 CODE FESTIVAL 2017 Final (Parallel) - Palindrome-phobia
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible. Constraints * 1 \leq |S| \leq 10^5 * S consists of `a`...
{"inputs": ["aba", "abac", "babacccabab", "acac", "bacaccbabab", "ccaa", "bacaacbcbab", "babcbcaacab", "bababccacab", "bacaccbabac", "bacaccbaaac", "caaabccacab", "caaaaccacab", "bacaccaaaac", "baa", "caba", "babacccbaab", "aacc", "bacabcbabab", "bacaacccbab", "babcbbaacab", "aacaccbabac", "caabaccacab", "bbcaccbaaac",...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to determine if we can permute the characters of a string S consisting of a, b, c such that there are no palindromic substrings of length 2 or more. Hmm. So the goal is to rearrange the characters so that no two consecutive characters are the same, and also no longer palindromes like aba...
To solve this problem, we need to determine if we can permute the characters of a given string such that it does not contain any palindromic substrings of length 2 or more. The key insight is to ensure that no two consecutive characters are the same and that no two characters are the same with exactly one character in ...
false
Code is incorrect.
16ae05016f16d8a236c4b261a54cbfea
p03694 AtCoder Beginner Contest 064 - Traveling AtCoDeer Problem
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and ...
{"inputs": ["4\n2 3 7 9", "8\n3 1 4 1 5 9 2 6", "4\n2 3 9 9", "8\n3 1 4 1 5 18 2 6", "4\n2 3 13 9", "4\n4 4 13 9", "8\n3 1 1 1 5 15 1 6", "4\n4 4 8 9", "4\n0 4 8 18", "8\n1 1 1 2 5 14 1 6", "4\n-1 2 4 18", "4\n-1 2 4 31", "8\n0 1 0 2 7 8 1 6", "4\n-1 2 11 6", "8\n1 1 -1 2 -1 0 1 5", "4\n-3 3 7 2", "8\n2 2 0 2 0 -1 0 1"...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to find the minimum distance AtCoDeer has to travel when visiting all the houses, and he can start and end anywhere. Hmm. So I need to figure out the optimal path here. Wait, the minimum distance. Since he can start and end anywhere, maybe the problem is similar to finding the shortest ...
To solve this problem, we need to determine the minimum distance AtCoDeer the reindeer has to travel to deliver gifts to all houses along TopCoDeer street, given that he can start and end his journey at any positions. ### Approach The key insight here is that the shortest path to visit all houses is to travel from the...
true
028f9ac24db128ead29476d6a4a6faf5
p03849 AtCoder Regular Contest 066 - Xor Sum
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7. Constraints * 1≦N≦10^{18...
{"inputs": ["3", "1422", "1000000000000000000", "4", "1026", "1000000001000000000", "0", "530", "1100000001000000000", "1", "706", "1100000001000010000", "2", "152", "1100000001001010000", "7", "192", "1100000011001010000", "5", "292", "1100000001001010010", "271", "1101000001001010010", "266", "1101000000001010010", "...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. I need to find the number of pairs (u, v) such that there exist non-negative integers a and b where a XOR b = u and a + b = v. And u and v are both between 0 and N, inclusive. The answer has to be modulo 1e9+7. Hmm. First, I remember that for a and b, the sum a + b is equal to (a XOR b) plus twice the...
To solve this problem, we need to count the number of pairs of integers (u, v) such that there exist non-negative integers a and b where a XOR b = u and a + b = v, with both u and v between 0 and N. The result should be computed modulo \(10^9 + 7\). ### Approach The key insight is that for any valid pair (u, v), v can...
false
Code is incorrect.
e2bd724d96c50b5ce5b4604138207478
p04015 AtCoder Regular Contest 060 - Tak and Cards
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection? Constraints * 1 \leq N \leq 50 * 1 \leq A \leq 50 * 1 \leq x_...
{"inputs": ["4 8\n7 9 8 9", "3 8\n6 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3", "8 5\n3 6 2 8 7 6 5 9", "4 8\n7 12 8 9", "3 8\n9 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "8 5\n3 6 2 8 7 2 5 9", "3 8\n15 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I need to solve this problem where Tak is selecting cards such that the average of the selected integers is exactly A. The task is to find out how many ways he can do this. Let's think about how to approach this. First, the average being A means that the sum of the selected numbers divided by the count of select...
To solve this problem, we need to determine the number of ways to select one or more cards such that the average of the integers on the selected cards is exactly A. The solution involves using dynamic programming to efficiently count valid subsets based on their size and sum. ### Approach 1. **Problem Analysis**: The ...
true
71c7db1543f13b9024515f01065dc92c
p00100 Sale Result
There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds ...
{"inputs": ["4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0", "4\n1001 2000 520\n80 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0", "4\n0001 2000 520\n80 1800 450\n1003 1600 625\n1...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to write a Python function that reads input data and processes each dataset to find employees whose total sales are at least 1,000,000. Let's break down the problem step by step. First, the input consists of multiple datasets. Each dataset starts with an integer n, followed by n lines of data. Each line h...
To solve this problem, we need to identify employees whose total sales proceeds meet or exceed 1,000,000 for each dataset provided. The solution involves processing each dataset independently and outputting the results in the order of the employees' first appearance in the dataset. ### Approach 1. **Reading Input**: T...
true
7c7deaa21786bdc72f5edf0168b4bc5b
p00232 Life Game
Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starting point, and the piec...
{"inputs": ["1 2 0\n1\n1 2 1\n1\n1 2 100\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 60\n0 0 0", "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 60\n0 0 0", "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 ...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. I need to solve this problem where I have to calculate the expected value of the money Taro ends up with when he reaches the goal. The problem seems a bit complex with events and probabilities, so I need to break it down step by step. First, let's understand the problem. The game is like a board with ...
To solve this problem, we need to calculate the expected value of the money Taro ends up with when he reaches the goal in a life game. The game involves moving pieces on a board according to a roulette wheel and event squares that can modify the position or money. The solution involves dynamic programming to model all ...
false
Code is incorrect.
d131b71ec3717527e93e10ceea27fba8
p00395 Maze and Items
Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objectiv...
{"inputs": ["12 5\n.....S......\n.abcdefghij.\n.0123456789.\n.ABCDEFGHIJ.\n.....T......\n0 1 0 0 0 0 0 0 0 0\n2 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0", "5 6\n..S..\n\n01234...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's tackle this problem. Hmm, the problem seems a bit complex, but I'll try to break it down step by step. So, the task is to find the minimum number of moves required to collect all items (digits 0-9) and then reach the goal T. And among all such paths with the minimal moves, we need to find the maximum possi...
To solve this problem, we need to find the minimum number of moves required to collect all items in a maze before reaching the goal, and among all such paths, determine the one with the maximum possible score based on the order of item collection. The maze has cells that can be accessible or inaccessible depending on t...
false
Code is incorrect.
0d85460dfc9d71a1495f7c47be58286e
p00610 Cleaning Robot 2
Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful. First, he renovated his house. Once his house had 9 rooms that were arranged in a square, but now his house has N × N rooms arranged in...
{"inputs": ["2 1\n2 3\n6 4\n0 0", "3 1\n2 3\n6 4\n0 0", "4 1\n2 3\n6 4\n0 0", "3 1\n4 3\n6 4\n0 0", "4 1\n1 3\n6 6\n0 0", "5 1\n4 3\n6 6\n0 0", "8 1\n1 3\n6 6\n0 0", "5 1\n4 3\n12 4\n0 0", "8 1\n1 3\n2 6\n0 0", "5 1\n4 3\n23 4\n0 0", "16 1\n1 3\n2 6\n0 0", "19 1\n1 3\n2 6\n0 0", "34 1\n1 6\n2 6\n0 0", "2 1\n3 3\n6 4\n0...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. The problem is to generate a specific carpet layout for an N x N grid such that there exists at least one initial placement of robots that ensures all rooms are eventually cleaned. And among all possible valid layouts, we need to output the K-th one lexicographically, considering 'E' comes before '.'. ...
To solve this problem, we need to generate a specific carpet layout for an N x N grid such that there exists at least one initial placement of robots that ensures all rooms are eventually cleaned. The solution must output the K-th lexicographically smallest valid layout or "No" if it does not exist. ### Approach 1. **...
false
Code is incorrect.
3bf8388875cfffd8af34a59dd77ca91c
p00748 Pollock's conjecture
The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) ⁄ 6. For example, the 5th tetrahedral number is 1+(1+2)+(1+2+3)+(1+2+3+4)+(1+2+...
{"inputs": ["40\n14\n5\n165\n120\n103\n106\n139\n0", "40\n14\n5\n165\n120\n133\n106\n139\n0", "40\n14\n5\n98\n120\n133\n106\n139\n0", "40\n14\n5\n98\n120\n133\n106\n150\n0", "40\n14\n5\n70\n120\n133\n106\n150\n0", "40\n14\n9\n70\n120\n133\n106\n150\n0", "40\n14\n9\n70\n72\n133\n106\n150\n0", "40\n14\n9\n29\n72\n133\n10...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where for a given number, I have to find the minimum number of tetrahedral numbers that sum up to it, and also the minimum using only odd tetrahedral numbers. Hmm. Let's start by understanding the problem. First, what's a tetrahedral number? Oh right, the nth tetrahedral number is n(...
To solve this problem, we need to verify Pollock's conjecture for individual integers by determining the minimum number of tetrahedral numbers (and odd tetrahedral numbers) required to represent each input integer as their sum. The approach involves precomputing tetrahedral numbers and using a breadth-first search (BFS...
true
cf28ca9d77b5b9e6e2c13f7f92a8026f
p00886 Towns along a Highway
There are several towns on a highway. The highway has no forks. Given the distances between the neighboring towns, we can calculate all distances from any town to others. For example, given five towns (A, B, C, D and E) and the distances between neighboring towns like in Figure C.1, we can calculate the distance matrix...
{"inputs": ["2\n1\n3\n5 3 2\n3\n6 3 2\n5\n9 8 7 6 6 4 3 2 2 1\n6\n9 8 8 7 6 6 5 5 3 3 3 2 2 1 1\n6\n11 10 9 8 7 6 6 5 5 4 3 2 2 1 1\n7\n72 65 55 51 48 45 40 38 34 32 27 25 24 23 21 17 14 13 11 10 7\n20\n190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171\n170 169 168 167 166 165 164 163 162 ...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. I need to solve this problem where I have to reconstruct the order of towns and the distances between consecutive towns based on the given pairwise distances. Hmm. The input is a list of all the pairwise distances sorted in descending order. My task is to find the possible sequences of distances betwee...
To solve this problem, we need to reconstruct the order of towns and the distances between consecutive towns based on the given pairwise distances. The input consists of a list of distances sorted in descending order, and our task is to determine the valid sequences of consecutive town distances that can generate these...
true
0b190b0672746706000cbd3ab9e0d646
p01017 Yu-kun Likes Rectangles
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves rectangles as much as programming. Yu-kun decided to write a program to calculate the maximum score that can be obtained, thinking of a new play to ge...
{"inputs": ["4 4\n10 2 -1 6\n8 1 -100 41\n22 47 32 11\n-41 99 12 -8\n1 0 0 1\n0 0 1 0\n0 1 0 1\n0 0 1 0\n2 3\n1 0 1\n0 1 0", "3 4\n4 1 9 1\n9 1 -1 3\n2 -4 1 10\n1 1 0 1\n0 1 1 1\n1 1 0 0\n1 4\n1 1 1 1", "3 3\n5 1 3\n2 5 9\n0 1 5\n1 0 0\n0 1 1\n0 1 1\n1 1\n1", "4 4\n10 2 -1 6\n8 1 -100 41\n22 47 32 11\n-41 99 12 -8\n1 0...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's required. The problem involves three rectangles: A, B, and C. The goal is to find all possible positions in rectangle B where the sub-rectangle exactly matches the pattern of C. For each such position, we calculate t...
To solve this problem, we need to find the maximum score obtained by matching a sub-rectangle from matrix B with matrix C and summing the corresponding values from matrix A. If no such sub-rectangle exists, we output "NA". ### Approach 1. **Input Reading**: Read the dimensions and values for matrices A, B, and C. 2. *...
false
Code is incorrect.
59d04f0e9c5b39dc2753daa0c97a587f
p01150 Eight Princes
Once upon a time in a kingdom far, far away, there lived eight princes. Sadly they were on very bad terms so they began to quarrel every time they met. One day, the princes needed to seat at the same round table as a party was held. Since they were always in bad mood, a quarrel would begin whenever: * A prince took t...
{"inputs": ["8\n16\n17\n0", "8\n6\n17\n0", "8\n23\n17\n0", "8\n6\n3\n0", "8\n0\n17\n0", "8\n30\n17\n0", "8\n6\n23\n0", "8\n23\n33\n0", "8\n1\n0\n0", "8\n30\n24\n0", "8\n6\n21\n0", "8\n40\n33\n0", "8\n15\n33\n0", "8\n5\n25\n0", "8\n23\n2\n0", "8\n39\n33\n0", "8\n52\n24\n0", "8\n20\n33\n0", "8\n9\n19\n0", "8\n44\n33\n0",...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's tackle this problem. So, we need to find the number of ways to seat eight princes around a round table with N seats such that no two princes are adjacent or opposite each other. Hmm, right. The output is the count for each N until 0 is input. First, let's understand the constraints. For a prince to not qua...
To solve this problem, we need to determine the number of ways to seat eight princes around a round table such that no two princes are adjacent or opposite each other. The solution must account for both even and odd numbers of seats, with different constraints for each case. ### Approach 1. **Even Number of Seats (N i...
false
Code is incorrect.
b4f298de837d68c0f92eaa9230af45b1
p01289 Strange Couple
Alice and Bob are going to drive from their home to a theater for a date. They are very challenging - they have no maps with them even though they don’t know the route at all (since they have just moved to their new home). Yes, they will be going just by their feeling. The town they drive can be considered as an undir...
{"inputs": ["5 1 5\n1 0 1 0 0\n0 2 1 0 0\n2 0 0 1 0\n1 0 0 1 0\n0 1 1 0 1\n0 0 0 1 0\n0 0 0", "5 1 5\n0 0 1 0 0\n0 2 1 0 0\n2 0 0 1 0\n1 0 0 1 0\n0 1 1 0 1\n0 0 0 1 0\n0 0 0", "5 1 5\n1 0 1 0 1\n0 2 1 0 0\n2 0 0 1 0\n1 0 0 1 0\n0 1 1 0 1\n0 0 0 1 0\n0 0 0", "5 1 5\n1 0 1 0 1\n0 2 1 0 0\n2 0 0 1 0\n1 0 0 1 0\n0 2 1 0 1\...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, so I have this programming problem to solve. Let's see what it's about. The problem is about Alice and Bob driving through a town represented as an undirected graph. They start at node s and need to reach node t. The nodes can have signs or not. At a node with a sign, they take the shortest path road. If there ar...
To solve this problem, we need to calculate the expected distance Alice and Bob will drive before reaching the theater, considering their navigation rules based on signs at intersections. The problem can be modeled using graph theory and linear algebra to solve a system of equations representing the expected distances....
false
Code is incorrect.
22f29e6ff0febb08bc84b8c3f1b82692
p01458 Kth Sentence
A student, Kita_masa, is taking an English examination. In this examination, he has to write a sentence of length m. Since he completely forgot the English grammar, he decided to consider all sentences of length m constructed by concatenating the words he knows and write the K-th sentence among the candidates sorted i...
{"inputs": ["3 3 6\na\naa\nb", "2 10 2\nhello\nworld", "2 59 1000000000000000000\na\nb", "3 3 4\na\naa\nb", "3 3 4\nb\naa\nb", "3 3 1\na\naa\nb", "2 10 0\nhello\nworld", "2 67 1000000000000000000\na\nb", "3 3 4\nc\naa\nb", "2 12 0\nhello\nworld", "2 132 1000000000000000000\na\nb", "3 5 4\nc\naa\nb", "2 12 1\nhello\nwor...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's tackle this problem. The task is to find the K-th lexicographically smallest sentence of exactly length m by concatenating words from a given list, with possible repetitions. If there aren't enough such sentences, output "-". First, I need to understand the problem deeply. Let's break it down. The key poi...
To solve this problem, we need to generate the K-th lexicographically smallest sentence of length exactly m using given words. The words can be reused any number of times, and the order of words matters even if the resulting string is the same. ### Approach 1. **Sort Words**: First, sort the words lexicographically t...
false
Code is incorrect.
722273a8ad8d7716b7028c9a6105b46b
p01609 One
One Problem Statement A beautiful mountain range can be seen from the train window. The window is a rectangle with the coordinates of the lower left corner (0, 0) and the coordinates of the upper right corner (W, H). N peaks can be seen from the window, and the i-th peak has the shape of an upwardly convex parabola y...
{"inputs": ["20 20 2\n-1 10 10\n-2 10 5", "15 100 2\n-2 5 100\n-2 10 100", "20 20 1\n-1 10 10", "20 20 2\n-1 10 10\n-2 10 9", "20 20 2\n-1 18 10\n-2 10 9", "20 20 2\n-1 18 10\n-2 10 3", "20 28 1\n-2 15 10", "20 28 1\n-2 15 16", "13 20 2\n-1 10 10\n-2 10 5", "20 20 2\n-1 10 7\n-2 10 9", "20 20 2\n-1 18 12\n-2 10 9", "20...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where I have to find the length of the boundary between the mountains (parabolas) and the sky as seen from a window. Let me think through this step by step. First, let's understand the problem. The window is a rectangle from (0,0) to (W,H). There are N parabolas, each defined by y = ...
To solve this problem, we need to determine the length of the boundary between the mountain ranges (represented by parabolas) and the sky as seen from a rectangular window. The solution involves calculating the upper envelope of these parabolas and ensuring it stays within the window's vertical boundaries. ### Approac...
false
Code is incorrect.
48ed653ff4224de003f544c1e1be9ebf
p01770 Arojam's Mask
Problem statement You are a hero. The world in which the hero is traveling consists of N cities and M roads connecting different cities. Road i connects town a_i and town b_i and can move in both directions. The purpose of the brave is to start from town S and move to town T. S and T are different cities. The hero ca...
{"inputs": ["8 5 2 0 5 5\n0 1\n0 3\n0 6\n1 2\n6 7\n3 4 7\n4 5 2", "8 5 2 0 5 5\n0 1\n0 3\n0 6\n1 2\n6 7\n1 4 7\n4 5 2", "8 5 2 0 5 5\n0 1\n0 3\n0 2\n1 2\n6 7\n3 4 7\n4 5 2", "8 5 2 0 5 5\n0 1\n0 3\n0 6\n1 2\n6 7\n1 4 7\n4 5 4", "8 5 2 0 5 5\n0 2\n0 3\n0 6\n1 2\n6 7\n1 4 7\n4 5 4", "8 5 2 0 3 5\n0 2\n0 3\n0 6\n1 2\n6 7\...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's tackle this problem. Hmm, the problem statement is a bit complex. Let me try to break it down. So, the hero needs to go from S to T, but can't take more than R days (roads) without blowing the ocarina, which resets them to S on day 0. Each time they blow the ocarina, that adds to their total count. The goa...
To solve this problem, we need to find the minimum sum of the number of moves required to reach city T from city S and the number of times the ocarina is blown, considering that roads can be added by events triggered when visiting specific cities. ### Approach 1. **Problem Analysis**: The hero can move between cities ...
false
Code is incorrect.
4fa6e7382e68c753d0738b05f502c105
p01904 Minimum Enclosing Rectangle
G: Minimum Enclosing Rectangle-Minimum Enclosing Rectangle- story Hello everyone! It's Airi Aiza from the Hachimori Naka Prokon Club. Suddenly, I want everyone to solve the problem that Airi couldn't solve before. I solved the A problem of ICPC2010 in this front activity, but the problem at that time was difficult. ...
{"inputs": ["1", "001", "001"], "outputs": ["1", "1.000000000\n", "1.000000000\n"]}
0
[ "PYTHON3" ]
6
2
code_contests
Okay, so I need to solve this problem where I have to find the minimum area rectangle that encloses a bunch of squares. The squares are placed according to some given directions. Let me think about how to approach this. First, let me understand the problem. Each square is placed adjacent to a previous one in one of fo...
To solve this problem, we need to determine the smallest axis-aligned rectangle that can enclose a set of squares placed on a two-dimensional plane according to specific adjacency instructions. The goal is to compute the area of this minimum enclosing rectangle. ### Approach 1. **Model the Positions**: Each square is ...
true
64eb5be7d935507e73684752b8b7ae21
p02042 ABSum
problem Given a sequence $ A $ of length $ N $. You can swap the $ i $ th and $ j $ th ($ 0 \ leq i, j \ leq N-1 $) elements of a sequence up to $ M $ times. Find the maximum value of $ \ sum_ {i = 0} ^ {N -1} abs (A_i --i) $ in the sequence created by the operation. output Find the maximum value of $ \ sum_ {i =...
{"inputs": ["5 2\n0 3 2 1 4", "5 2\n0 1 2 1 4", "5 2\n0 1 0 1 0", "5 2\n0 1 0 1 -1", "5 3\n-1 1 0 2 -1", "2 2\n0 1 2 1 4", "1 2\n0 1 0 1 0", "4 3\n0 1 0 2 -1", "2 3\n-1 1 0 2 -1", "2 3\n-2 1 0 2 -1", "5 2\n0 0 4 1 4", "5 2\n0 0 4 2 4", "2 3\n0 0 -1 2 -1", "9 1\n1 0 4 2 0", "9 1\n1 1 4 2 0", "9 1\n0 1 7 2 0", "4 2\n0 1 ...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. The problem is about finding the maximum possible sum of absolute differences after performing up to M swaps. Hmm, how do I approach this? So the initial thought is: each swap allows us to exchange two elements in the array. We want to maximize the sum of |A[i] - i| for all i. But how to model this op...
To solve this problem, we need to maximize the sum of the absolute differences between each element and its index in an array after performing up to M swaps. The goal is to determine the optimal swaps that yield the highest possible sum. ### Approach The approach involves iteratively selecting the pair of indices (i, ...
false
Code is incorrect.
0a64352b6a1bc74ef05d21f0e08bc281
p02185 Many Decimal Integers
D: Many Decimal Integers problem Given a string S consisting only of numbers (0-9) and a string T consisting only of numbers and `?`. S and T are the same length. Consider changing each `?` That exists in T to one of the numbers from 0 to 9 to create the string T'consisting of only numbers. At this time, it must be ...
{"inputs": ["73\n6?", "73\n?6", "73\n@6", "73\n5?", "73\n?5", "73\n4?", "73\n?4", "73\n?8", "73\n?7", "73\n7?", "73\n?3", "73\n3?", "73\n?9", "73\n?2", "73\n70", "73\n1?", "73\n27", "73\n?1", "73\n49", "73\n72", "73\n59", "73\n?0", "73\n69", "73\n21", "73\n11", "73\n64", "73\n54", "73\n??", "73\n10", "73\n48", "73\n29"...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's try to solve this problem. Hmm, the problem says that we have two strings S and T of the same length. We need to replace the '?' in T with digits to form T', such that when we interpret both S and T' as numbers, T' is less than or equal to S. Then, we need to sum all possible valid T' values and output the ...
To solve this problem, we need to generate all possible valid strings T' by replacing '?' in the string T with digits such that the numeric value of T' is less than or equal to the numeric value of S. We then sum the values of all valid T' strings and return the result modulo \(10^9 + 7\). ### Approach 1. **Dynamic Pr...
false
Code is incorrect.
fa1e014c0474b2adfcdbadc6174ddcfe
p02327 Largest Rectangle
Given a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s. Constraints * 1 ≤ H, W ≤ 1,400 Input H W c1,1 c1,2 ... c1,W c2,1 c2,2 ... c2,W : cH,1 cH,2 ... cH,W In the first line, two integers H and W separated by a space character are given. In the following...
{"inputs": ["4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0", "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0", "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 1\n0 0 0 1 0", "1 5\n0 0 1 0 0\n1 0 0 0 1\n0 0 0 1 0\n0 0 0 1 0", "0 5\n0 0 1 -1 0\n1 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0", "1 5\n1 0 1 0 1\n2 0 -1 0 1\n0 -1 0 0 0\n0 0 0 1 0",...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where I have to find the largest rectangle consisting of only 0s in a given matrix. Let me think about how to approach this. First, I remember that there's a well-known algorithm for finding the largest rectangle in a histogram. Maybe I can use a similar approach here. Oh right! The ...
To solve this problem, we need to find the area of the largest rectangle composed solely of 0s in a given binary matrix. The solution leverages the concept of converting each row of the matrix into a histogram of consecutive 0s and then finding the largest rectangle in that histogram. ### Approach 1. **Convert Rows to...
true