Greetings From Globussoft: Search Engine Like Google, Yahoo, Bing
Greetings From Globussoft: Search Engine Like Google, Yahoo, Bing
Greetings From Globussoft: Search Engine Like Google, Yahoo, Bing
While solving these questions you are not allowed to use any
Search Engine like Google, Yahoo, Bing …
Constraints
1 ≤ N , M ≤ 1000
1≤A≤N
1≤B≤M
0≤C≤A-2
0≤D≤B-2
Input
The first line of the input contains an integer t (1 ≤ t ≤ 10 ), equal to the number of testcases. Then
descriptions of t testcases follow. The first line of the description contains 6 integer numbers N, M,
A, B, C, D. Then N lines follow, line i contains one integer number P[i][1].
Output
For each test case, your program should output the maximal difference between two matrices (in a
separate line).
Example:
Input
1
333311
1
2
3
Output
260
Question: - 2
Vladimir worked for years making matrioshkas, those nesting dolls that certainly represent truly
Russian craft. A matrioshka is a doll that may be opened in two halves, so that one finds another doll
inside. Then this doll may be opened to find another one inside it. This can be repeated several times,
till a final doll -that cannot be opened- is reached.
Recently, Vladimir realized that the idea of nesting dolls might be generalized to nesting toys. Indeed,
he has designed toys that contain toys but in a more general sense. One of these toys may be opened
in two halves and it may have more than one toy inside it. That is the new feature that Vladimir wants
to introduce in his new line of toys.
Vladimir has developed a notation to describe how nesting toys should be constructed. A toy is
represented with a positive integer, according to its size. More precisely: if when opening the toy
represented by m we find the toys represented by n1, n2, . . ., nr, it must be true that n1 +n2 +. . .+nr
< m. And if this is the case, we say that toy m contains directly the toys n1, n2, . . ., nr . It should be
clear that toys that may be contained in any of the toys n1, n2, . . ., nr are not considered as directly
contained in the toy m.
A generalized matrioshka is denoted with a non-empty sequence of non zero integers of the form: a1
a2 . . . aN such that toy k is represented in the sequence with two integers −k and k, with the negative
one occurring in the sequence first that the positive one.
−9 −7 −2 2 −3 −2 −1 1 2 3 7 9
On the other hand, the following sequences do not describe generalized matrioshkas:
−9 −7 −2 2 −3 −1 −2 2 1 3 7 9
because toy 2 is bigger than toy 1 and cannot be allocated inside it.
−9 −7 −2 2 −3 −2 −1 1 2 3 7 −2 2 9
Input
The input file contains several test cases, each one of them in a separate line. Each test case is a
sequence of non zero integers, each one with an absolute value less than 10^7.
Output
Output texts for each input case are presented in the same order that input is read. For each test case
the answer must be a line of the form
:-) Matrioshka!
if the design describes a generalized matrioshka. In other case, the answer should be of the form
Example:
Input
-9 -7 -2 2 -3 -2 -1 1 2 3 7 9
-9 -7 -2 2 -3 -1 -2 2 1 3 7 9
-9 -7 -2 2 -3 -1 -2 3 2 1 7 9
-100 -50 -6 6 50 100
-100 -50 -6 6 45 100
-10 -5 -2 2 5 -4 -3 3 4 10
-9 -5 -2 2 5 -4 -3 3 4 9
Output
:-) Matrioshka!
:-( Try again.
:-( Try again.
:-) Matrioshka!
:-( Try again.
:-) Matrioshka!
:-( Try again.
Question: - 3
BuggyD has always been fascinated with chess boards (though he really sucks at chess). He makes
an observation that a chess board is complete with respect to knights and rooks and incomplete with
respect to bishops (unless the dimensions are 1 × 1). A complete chess board is one in which it is
possible to traverse all the squares starting from one possible square. Knights have always been his
favourite pieces and he has decided to analyze completeness with respect to knights. Given the
dimesions of the chess board help BuggyD find the lexicographically first path that visits all squares
of a chess board with a knight.
Each square must be traversed only once. Note that a knight can only move two squares in one
direction and one square perpendicular to the previous direction.
Input
The first line of the input contains an integer t, the number of test cases. t test cases follow.
Each test case consists of a single line cotaining two integers (X and Y) separated by a single space,
specifying the dimensions of the chess board. The numbers 1 to X denote rows and the capital letters
A to Y denote the coloumns. Each square is represented by its column index followed by it's row
index - for example, B4 denotes the square in the 4th row and 2nd column.
The total number of squares on the chess board will be no more than 26.
Output
For each test case output one line consisting of the lexicographically first path of the knight, or "-1"
(quotes for clarity) if the chess board is incomplete with respect to a knight.
Example:
Input
1
45
Output
A1B3C1A2B4D3E1C2D4E2C3A4B2D1E3C4A3B1D2E4
Question: - 4
Nikifor and Trofim play the following game: they write some integer smaller then 2000000000 and
take turns one after another. Nikifor is the first to make a move. The turn is made by the following
rule: from the written integer any non-zero digit is subtracted, and the new integer replaces the old
one on the desk. For example for integer 40534, the next move can be: 40530, 40531 or 40529. The
winner is the player who writes zero on the desk.
Write a program to decide who will win if both players do their best.
Input
The input contains the integer from which the game is started.
Output
In the first line you must write 1 if Nikifor wins and 2 otherwise. If Nikifor wins then in the second
line you must output the move in the first turn which guarantees victory for him. If there are many
such moves then output any of them.
Example:
Input
14
Output
1
4
Question: - 5
In a rectangular field of size n by m squares there is a mouse and two cats. The mouse is the first to
make a move, then each of the cats makes a move, then again its the mouse's turn, and so on. In each
move both the mouse and the cats can move exactly one square vertically or horizontally. If the
mouse is standing at the edge of the field then in its next move it can jump off the field and is saved
from the cats. If in the next move one of the cats moves to the field with the mouse then there is no
escape for the mouse ... =(
You are to write a program which, knowing the initial positions of mouse and the two cats, will find
out if there is any way for the mouse to escape from the cats, assuming of course that each cat will
do its best to catch the mouse.
Input
In the first line of input two integers n and m are given, not exceeding 100, where n is the number of
rows, and m - the number of columns. The second line contains a number k [k <= 10], which defines
the number of test cases for the given field. In the next k lines the initial positions of the mouse and
the cats are given. The position in the field is given by two numbers: the first is the number of the
row, the second is the number of the column. The first two integers are the coordinates of the mouse,
the next four integers are the coordinates of the cats.
Output
You must output k lines with answers for each test case. The answer is YES, if the mouse can escape
or NO otherwise.
Example:
Input
53
3
221133
231352
321243
Output
NO
YES
YES