id
stringlengths
12
36
text
stringlengths
1
621k
AW8CIB5LZH9L
The princess is going to escape the dragon's cave, and she needs to plan it carefully. The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess ...
IHGH650YYSG3
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`...
TBH4G1Z4ARHD
Write a planning document that analyzes and compares all plausible algorithmic approaches to the given problem, narrates the reasoning behind each, and outlines a high-level implementation plan for the chosen method, all in a smooth, student-like prose style. You might have remembered Theatre square from the [problem 1...
GISYXODUR2TK
Marut is now a well settled person. Impressed by the coding skills of Marut, N girls wish to marry him. Marut will consider marriage proposals of only those girls who have some special qualities. Qualities are represented by positive non-zero integers. Marut has a list of M qualities which he wants in a girl. He can a...
ITBM1KJBZK1D
Write a planning document that analyzes and compares all plausible algorithmic approaches to the given problem, narrates the reasoning behind each, and outlines a high-level implementation plan for the chosen method, all in a smooth, student-like prose style. A histogram is made of a number of contiguous bars, which ha...
1H0ZFO6TNX6V
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_...
5HZ8GKO2P9I0
Yes, you read it right - Little Jhool is back, but no, he's not over his break up, still. And he's sad, broken and depressed; thus, he decided to visit a psychologist. She tells him to think about his pleasant memories of childhood, and stay busy so as to not miss his ex-girlfriend. She asks him about his favorite mem...
I5OB87Q7AUK8
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish. For the given positive integer N, your ta...
LS1G3ZY7LHKG
Summarize the problem in your own words, independently develop and compare all plausible algorithmic approaches, evaluate them, select the best option, and provide a detailed, prose-style high-level plan for its implementation. You are given a simple code of a function and you would like to know what it will return. ...
YUQULSQJPLZR
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree? Then he found that such tree-like graphs are called 1-trees. Since Gildong was bored of solving too many tree problems, he wan...
G6O1JEPHB4DS
Write a planning document that narratively explores all algorithmic ideas for solving the given problem, compares them, selects the best one, and outlines its high-level implementation without referencing any supporting materials or showing code. You are given a sequence of length N: A_1, A_2, ..., A_N. For each intege...
JHJ1DF2M95UC
Write a planning document for solving the given algorithmic problem, including a narrative exploration of candidate approaches, comparative evaluation, and a high-level implementation outline, following specific style and content guidelines. There are N cubes stacked vertically on a desk. You are given a string S of l...
OJJROTYFI4DE
Gerald has a friend, Pollard. Pollard is interested in lucky tickets (ticket is a sequence of digits). At first he thought that a ticket is lucky if between some its digits we can add arithmetic signs and brackets so that the result obtained by the arithmetic expression was number 100. But he quickly analyzed all such ...
4ZFBTCPOX4X8
Write a detailed planning document that explores, compares, and outlines high-level steps for all plausible algorithmic ideas for the given problem, presenting each approach as if independently conceived and selecting the best one through careful narrative reasoning. There are n psychos standing in a line. Each psycho ...
OW54T298AVHY
Write a planning document that explores multiple algorithmic ideas for the given problem, evaluates them comparatively, and provides a high-level, prose-only outline of the best solution, all presented as if independently reasoned without referencing any external materials. Takahashi wants to print a document with N pa...
N29DALXQMKJZ
Write a planning document that explores, compares, and outlines independent approaches for solving the given algorithmic problem, presenting each technique as though you devised it through your own analysis. Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everythin...
VU92TJ09E8C2
Write a planning document that narratively explores all algorithmic ideas for solving the given problem, compares them, selects the best one, and outlines its high-level implementation without referencing any supporting materials or showing code. The educational program (AHK Education) of the Aiz Broadcasting Associati...
21D3DFSNKXK1
Cowboy Vlad has a birthday today! There are n children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a circle arbitrarily, it may turn out, that there is a tall and low child standing n...
HR0YA5U3KM4Y
Write a planning document that explores, compares, and outlines high-level steps for all your independently derived algorithmic approaches to the given problem, presenting your reasoning process in a student-like, prose narrative without code or references. You are given two integers a and b, and q queries. The i-th qu...
98M8U20LA8E4
Summarize the problem and independently develop a detailed planning document that explores, evaluates, and outlines high-level steps for all plausible algorithmic approaches to solve it, presenting each as though you arrived at it through your own reasoning. As you know Appu created aversion to Maths after that maths p...
IF0F5SZAD6Y5
It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills. According to the borscht recipe it consists of n ingredients that have to be mixed in propor...
W8VSWJB6KJV6
A certain business maintains a list of all its customers' names. The list is arranged in order of importance, with the last customer in the list being the most important. Now, he want to create a new list sorted alphabetically according to customers' last names, but among customers with the same last name he want the m...
RD9S3RS62DC4
Write a planning document that explores and compares several algorithmic approaches to the given problem, ultimately selecting and outlining the most suitable method through a narrative, step-by-step explanation. Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its...
E97QVWQWJQPP
Write a planning document that explores, compares, and outlines candidate algorithmic approaches to the given problem, following a detailed, narrative style and specified structure. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occur...
9LMRKWZEAJES
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is <image> for SmallR while <image> for Zanoes. The one who shoots in the target first should be the winner. Output the probability th...
YLRD1MH9IGHC
Write a planning document that explores multiple algorithmic ideas for the given problem, evaluates them comparatively, and provides a high-level, prose-only outline of the best solution, all presented as if independently reasoned without referencing any external materials. Find the intersection of two sets $A = \\{a_0...
R3TU1PUIQU7O
Let's call an array t dominated by value v in the next situation. At first, array t should have at least 2 elements. Now, let's calculate number of occurrences of each number num in t and define it as occ(num). Then t is dominated (by v) if (and only if) occ(v) > occ(v') for any other number v'. For example, arrays [1...
OZDKPMUI5WU0
When Masha came to math classes today, she saw two integer sequences of length n - 1 on the blackboard. Let's denote the elements of the first sequence as a_i (0 ≤ a_i ≤ 3), and the elements of the second sequence as b_i (0 ≤ b_i ≤ 3). Masha became interested if or not there is an integer sequence of length n, which e...
P8H9Z73GTGV6
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ...
MLNJGJVGFQ7Z
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness". The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to ...
19XOLKQZR88E
Write a planning document that presents and compares every algorithmic approach relevant to the problem, justifies the best choice, and outlines in narrative form the high-level steps for its implementation. Computation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calcula...
RUSQP5JAF8R6
This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), coun...
6D18EQA5H4SY
After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades. Orpheus, a famous poet, and musician plans to calm Cerberus with his poe...
ZY7BR3HAZJLH
Takahashi likes the sound when he buys a drink from a vending machine. That sound can be heard by spending A yen (the currency of Japan) each time. Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time. How many times will he h...
UUP8Y6PRNF3E
For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M. Constraints * 1 ≤ m ≤ 100 * 1 ≤ n ≤ 109 Input m n Two integers m and n are given in a line. Output Print mn (mod 1,000,000,007) in a line. Examples Input 2 3 Output 8 Input 5 8 Output ...
RE020XMXYYJY
Write a planning document that explores, compares, and outlines high-level steps for possible algorithmic approaches to the given problem, presenting all ideas in a narrative, student-like style without referencing any provided materials or code. Innopolis University scientists continue to investigate the periodic tabl...
UIXK78KPYEAW
Write a planning document that explores, evaluates, and outlines possible algorithmic approaches to solve the given problem, following a structured narrative style and specific content guidelines. Tsuruga Castle, a symbol of Aizuwakamatsu City, was named "Tsuruga Castle" after Gamo Ujisato built a full-scale castle tow...
79H1FCBADZCX
Example Input 2 -3 4 L 2 5 ? 3 5 Output 2 L 4 L 3 Write a planning document that narratively explores all algorithmic ideas for solving the given problem, compares them, selects the best one, and outlines its high-level implementation without referencing any supporting materials or showing code. The task is to pro...
Q5C0OVE8E9J9
Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to ta...
Q44GVTWFEM5U
Write a planning document that explores, compares, and outlines the implementation of independently developed algorithmic approaches to the given problem, following a student-like narrative and specified structural guidelines. Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feed...
II0AZ5V8UUXP
You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d...
7SZ1C1UG98Z8
Write a detailed planning document that analyzes and compares all viable algorithmic approaches for solving the given problem, narrates the reasoning behind each, evaluates their merits and drawbacks, selects the most suitable method, and outlines a high-level step-by-step strategy for implementing it—all in a fluent, ...
LKW9YJU90R3T
Write a detailed planning document that explores, compares, and outlines algorithmic approaches to solve the given problem, presenting all ideas and reasoning as if independently developed. 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 n...
8C8H8L81PGPA
Write a planning document that explores and compares multiple algorithmic approaches to a given problem, explains the reasoning behind each, and outlines an implementation plan for the best method, all in a narrative, student-like style without referencing any external materials. Berland starts to seize the initiative ...
3ULFRAP1N1JJ
This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved. There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1). In ...
UFE526XZC4CQ
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
HCOPSVFBORHB
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
RC2O16EJPUEQ
You are given a string s consisting of n lowercase Latin letters. Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't substrings of this string. So the substring of the string s from po...
LFDTNT1XQN9Y
Given a problem statement and solution approaches, write a planning document that explores candidate algorithms, compares them, and outlines a high-level solution strategy in a narrative, student-like style. We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each...
ZGPZ8VZDLZ1O
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store — "PriceFixed". Here are some rules of that store: * The store has an infinite number of items of every product. * All products have the same price: 2 rubles per item. * ...
VB9N4SNVFJ9T
Write a planning document that explores and evaluates all plausible algorithmic approaches to the given problem, narratively justifies each, and provides a detailed high-level outline for implementing the chosen solution, all in smooth, student-style prose without referencing any external materials. Natasha is going to...
7NTAUDJJFT20
Write a planning document that explores, compares, and outlines high-level steps for possible algorithmic approaches to the given problem, presenting all ideas in a narrative, student-like style without referencing any provided materials or code. problem AOR Ika is studying to pass the test. AOR Ika-chan solved the $...
F4E90I54OYBK
Write a detailed planning document that explores, compares, and outlines high-level steps for all plausible algorithmic strategies to solve the given problem, presenting your reasoning and approach selection in a natural, student-like narrative style. Bash has set out on a journey to become the greatest Pokemon master....
C5ZS5KW40LWA
Write a detailed planning document that explores, compares, and outlines high-level steps for every plausible algorithmic approach to the given problem, narrating your thought process and reasoning throughout. C: Prayer (Pray) Some twins are famous for praying before the contest. There are four integers \(H, W, X, Y\...
CO78HXIYUXL2
Vicky, the Artist, had two lists A and B, such that B was a permutation of A. Vicky was very proud of these lists. Unfortunately, while transporting them from one exhibition to another, some numbers were left out of A. Can you find the missing numbers? If a number occurs multiple times in the lists, you must ensure tha...
6E123DUUXK2D
Write a planning document that presents and compares every algorithmic approach relevant to the problem, justifies the best choice, and outlines in narrative form the high-level steps for its implementation. Problem E: Anipero The long and short summer, which had been hot, was about to end. One day in late August, a p...
FSFGE3V21ESS
Summarize and narratively compare all algorithmic approaches you independently develop for the given problem, evaluate them, select the best, and outline a high-level implementation plan—all in a student-style planning document with no code or references. Dawid has four bags of candies. The i-th of them contains a_i ca...
M9U302GPG0C1
Write a planning document that explores, compares, and outlines high-level steps for independently developed algorithmic approaches to the given problem, presenting each method as though conceived through your own reasoning process. A convex polygon consisting of N vertices is given. The coordinates of each vertex are ...
SBME65ZRTH98
Write a detailed planning document that explores, compares, and outlines candidate algorithmic approaches to solve the given problem, presenting all ideas as if independently developed and strictly following the specified narrative and content structure. Draw a frame which has a height of H cm and a width of W cm. For ...
W2F8VXWVN4KD
Summarize and plan how to solve the given algorithmic problem by independently exploring and evaluating multiple solution strategies, selecting the most suitable one, and outlining its high-level implementation in a detailed, narrative style. One day little Vasya found mom's pocket book. The book had n names of her fri...
B26Y0P890JD6
There are n people sitting in a circle, numbered from 1 to n in the order in which they are seated. That is, for all i from 1 to n-1, the people with id i and i+1 are adjacent. People with id n and 1 are adjacent as well. The person with id 1 initially has a ball. He picks a positive integer k at most n, and passes th...
SW8TT8MFQ98K
A permutation — is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] — permutations, and [2, 3, 2], [4, 3, 1], [0] — no. Polycarp was recently gifted a permutation a[1 ... n] of length n. Polycarp likes trees more than permutations, s...
7R28LAA4P2IR
Let's write all the positive integer numbers one after another from 1 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536... Your task is to print the k-th digit of this sequence. Input The first and only line...
XSK856P2U2QL
You are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors - one from the left and one from the right. You perform a sequence of operations on this set of p...
CJK8AV9359FX
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T: * M v: (Mark) Mark node v. * Q v: (Query) Print the index of the nearest marked ancestor of node v which is nearest to it. Initially, only the root no...
23W4JJJI42QW
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles: <image> It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar pi...
3QH5IILUL437
Write a detailed planning document that explores, compares, and outlines high-level steps for all plausible algorithmic strategies to solve the given problem, presenting your reasoning and approach selection in a natural, student-like narrative style. problem Given a sequence $ A $ of length $ N $. You can swap the $ ...
RFZHO5HD2WM0
During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so he asks you to help. You are given a sequence a, consisting of n distinct integers, that is used to construct the binary search tree. Below is the formal d...
9P6UGY5V7XLX
The only difference between the two versions of the problem is that there are no updates in the easy version. There are n spools of thread placed on the rim of a circular table. The spools come in two types of thread: the first thread is black and the second thread is white. For any two spools of the same color, you ...
X5WT7SS3MZ74
Polycarp has an array a consisting of n integers. He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its...
11FX5NW8U8CK
Taro's Shopping Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceedin...
8VX18QFCS0SI
Mattey has an assignment that he should submit tomorrow. The assignment has one question which asks to write a program to multiply two numbers without using ''* operator. As Mattey finds no interest in this subject, he never listens to classes and so do not know about shift operators. He comes to you to learn about th...
EI0XA3S5H450
Medicine faculty of Berland State University has just finished their admission campaign. As usual, about 80\% of applicants are girls and majority of them are going to live in the university dormitory for the next 4 (hopefully) years. The dormitory consists of n rooms and a single mouse! Girls decided to set mouse tra...
XPSLMJ1PXKFG
Write a planning document that narratively explores, compares, and outlines high-level steps for all algorithmic approaches to the given problem, as though you independently developed them. bhargav has dream to study his MS is foreign country. So, He started his preparation for GRE. There are huge number of words that ...
2NY78I0LEYHX
The much anticipated video game "BiCo Grid" has been released. The rules of "Bico Grid" are very simple. The game field is a 100x100 matrix, where each cell is either a blocked cell, or a cell with some number of coins. For a regular player the look of the field seems pretty random, but the programmer in you recognizes...
42I54EFGEZDG
The king of ghosts is really disappointed when he sees that all the human beings on Planet Earth have stopped fearing the ghost race. He knows the reason for this. The existing ghost race has become really lazy and has stopped visiting Planet Earth to scare the human race. Hence, he decides to encourage the entire ghos...
V3PIVHG15A60
Summarize and explain, in a detailed planning document, all plausible algorithmic approaches to the given problem, compare them, select the best one, and outline its implementation in a narrative, step-by-step manner without using code. Bob loves sorting very much. He is always thinking of new ways to sort an array.His...
PJ7HO98KJJJE
Write a planning document that explores, compares, and outlines high-level steps for all major algorithmic approaches you independently develop while analyzing the given problem. problem Given the sequence $ A $ of length $ N $. Find the maximum value of $ \ sum B_i $, where $ B $ is one of the longest increasing subs...
RFRX4XFBIJC8
Write a detailed planning document that explores, compares, and outlines high-level steps for all plausible algorithmic ideas for the given problem, presenting each approach as if independently conceived and selecting the best one through careful narrative reasoning. There is new delicious item in Chef's menu - a dough...
452IO7TH6OKN
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character spends fixed time to raise a weapon and then he hits (the time to...
MB7NJVNP59QG
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out). For \(n\) stack \(S_i\) (\(i = 0, 1, ..., n-1\)), perform a sequence of the following operations. * push(\(t\), \(x\)): Insert an integer \(x\) to \(S_t\). * top(\(t\)): Report the value which should be deleted next ...
ESE2WVHLY6ED
Write a planning document that explores multiple algorithmic approaches to a given problem, compares them, and outlines the steps for implementing the best approach, all in a student-like narrative style without referencing any provided materials. As it's the first of April, Heidi is suspecting that the news she reads ...
EABJILYN1GC9
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its diameter is at most K. You are given an undirected tree with N verti...
GL9AJUVHBWZA
Write a planning document that explores, compares, and outlines high-level steps for all major algorithmic approaches to the given problem, presenting each method as if independently conceived and without referencing any external materials. Problem description One of the Engineer friends of John, Mr. Dev tried to devel...
RPRAGLCJQ1UU
Write a planning document that analyzes multiple algorithmic approaches to the given problem, explains their merits and drawbacks, compares them, selects the most suitable one, and outlines its implementation in a detailed, narrative style without using code. Sasha reaches the work by car. It takes exactly k minutes. O...
ML4FEMKLQKEP
Write a detailed, student-style planning document that explores, compares, and outlines all algorithmic ideas for solving the given problem, presenting each approach as your own independent reasoning and following the specified narrative and structural guidelines. For a dictionary \(M\) that stores elements formed by a...
XSIO9CU4A365
Write a detailed planning document that explores, compares, and outlines high-level steps for all plausible algorithmic strategies to solve the given problem, presenting your reasoning and approach selection in a natural, student-like narrative style. Problem Create a program that performs the following types of opera...
BFT4D0TLRTQ5
Write a detailed planning document that explores, compares, and outlines algorithmic approaches to solve the given problem, presenting all ideas and reasoning as if independently developed. AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_...
O4KDJK5WEJZV
Summarize the problem and independently narrate the exploration, comparison, and high-level planning of all algorithmic approaches hinted at, culminating in a detailed, prose-style planning document. Milly is playing with an Array A of size N. She wants to convert this array into a magical array. This magical array sat...
C9SC03Y8DI0A
You are given an undirected graph consisting of n vertices and <image> edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge between x and y, and if some pair of vertices is not listed in the input, then there is an edge between these vertices. ...
MOMT8LVOMUTZ
Given a string s, process q queries, each having one of the following forms: * 1 i c — Change the i-th character in the string to c. * 2 l r y — Consider the substring of s starting at position l and ending at position r. Output the number of times y occurs as a substring in it. Input The first line of the input...
HTAV8HM0G7PI
Mike likes strings. He is also interested in algorithms. A few days ago he discovered for himself a very nice problem: You are given an AB-string S. You need to count the number of substrings of S, which have an equal number of 'A'-s and 'B'-s. Do you know how to solve it? Good. Mike will make the problem a little ...
0GTGNY6J4IYN
Finally Fox Ciel arrived in front of her castle! She have to type a password to enter her castle. An input device attached to her castle is a bit unusual. The input device is a 1 × n rectangle divided into n square panels. They are numbered 1 to n from left to right. Each panel has a state either ON or OFF. Initially...
TWD8051K1T85
Write a planning document that explores all promising algorithmic approaches for solving the given problem, evaluates their merits and drawbacks, selects the best method, and outlines its implementation in a detailed, narrative style. Vasya and Kolya play a game with a string, using the following rules. Initially, Koly...
RQV89USIO5ZZ
Write a planning document for solving a given algorithmic problem, following a narrative "think-aloud" style that explores, compares, and outlines all candidate approaches in detail without referencing any provided resource material. Berland Football Cup starts really soon! Commentators from all over the world come to ...
VJMVE9WBDYUK
Write a detailed planning document that explores, compares, and outlines candidate algorithmic approaches to solve the given problem, presenting all ideas as if independently developed and strictly following the specified narrative and content structure. I decided to move and decided to leave this place. There is nothi...
9SAYYN6MG7XO
Write a planning document that analyzes the problem, independently develops and narratively evaluates all major algorithmic ideas, compares them, recommends the best approach, and outlines a high-level, prose-only implementation plan. Valera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes,...
SLEW66APLZ72
Summarize and plan how to solve the given algorithmic problem by independently exploring and evaluating multiple solution strategies, selecting the most suitable one, and outlining its high-level implementation in a detailed, narrative style. Ayoub thinks that he is a very smart person, so he created a function f(s), w...
P02ON1L9F6N6
ZS the Coder has drawn an undirected graph of n vertices numbered from 0 to n - 1 and m edges between them. Each edge of the graph is weighted, each weight is a positive integer. The next day, ZS the Coder realized that some of the weights were erased! So he wants to reassign positive integer weight to each of the edg...
O7L2NC0SCC7P
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph. <image> Example of a tree. You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color. You have to paint the vertices so that any path consisting of exactly th...