Globbusoft 02 Java
Globbusoft 02 Java
While solving these questions you are not allowed to use any
Search Engine like Google, Yahoo, Bing …
Globussoft
Question: - 1
In digital recording, sound is described by a sequence of numbers representing the air pressure,
measured at a rapid rate with a fixed time interval between successive measurements. Each value in
the sequence is called a sample. An important step in many voice-processing tasks is breaking the
recorded sound into chunks of non-silence separated by silence. To avoid accidentally breaking the
recording into too few or too many pieces, the silence is often defined as a sequence of m samples
where the difference between the lowest and the highest value does not exceed a certain treshold c.
Write a program to detect silence in a given recording of n samples according to the given parameter
values m and c.
Input
The first line of the file contains three integers: n (1 ≤ n ≤ 1,000,000), the number of samples in the
recording; m (1 ≤ m ≤ 10,000), the required length of the silence; and c (0 ≤ c ≤ 10,000), the maximal
noise level allowed within silence. The second line of the file contains n integers ai (0 ≤ ai ≤ 1,000,000
for 1 ≤ i ≤ n), separated by single spaces: the samples in the recording.
Output
The file should list all values of i such that max(a[i . . . i + m − 1]) − min(a[i . . . i + m − 1]) ≤ c. The
values should be listed in increasing order, each on a separate line. If there is no silence in the input
file, write NONE on the first and only line of the output file.
Example:
Input:
720
0112322
Output:
2
6
Question: - 2
A group of war prisoners are trying to escape from a prison. They have thoroughly planned the
escape from the prison itself, and after that they hope to find shelter in a nearby village. However,
the village (marked as B, see picture below) and the prison (marked as A) are separated by a canyon
which is also guarded by soldiers. These soldiers sit in their pickets and rarely walk; the range of
view of each soldier is limited to exactly 100 meters. Thus, depending on the locations of soldiers, it
may be possible to pass the canyon safely, keeping the distance to the closest soldier strictly larger
than 100 meters at any moment.
You are to write a program which, given the width and the length of the canyon and the coordinates
of every soldier in the canyon, and assuming that soldiers do not change their locations, first
determines whether prisoners can pass the canyon unnoticed. If this is impossible then the prisoners
(having seen enough violence) would like to know the minimum number of soldiers that have to be
eliminated in order to pass the canyon safely. A soldier may be eliminated regardless of whether he
is visible to any other soldier or not.
Input
The first line contains three integers L, W , and N – the length and the width of the canyon, and the
number of soldiers, respectively. Each of the following N lines contains a pair of integers Xi and Yi –
the coordinates of i-th soldier in the canyon (0 ≤ Xi ≤ L, 0 ≤ Yi ≤ W ). The coordinates are given in
meters, relative to the canyon: the southwestern corner of the canyon has coordinates (0, 0), and the
northeastern corner of the canyon has coordinates (L, W ), as seen in the picture above.
Note that passing the canyon may start at coordinate (0, ys ) for any 0 ≤ ys ≤ W and end at coordinate
(L, ye ) for any 0 ≤ ye ≤ W . Neither ys nor ye need to be integer.
Output
In the first and only line of the output file the program should print the minimum number of soldiers
that have to be eliminated in order for the prisoners to pass the canyon safely. If the prisoners can
escape without any elimination, the program should print 0 (zero).
Constraints
1 ≤ W ≤ 50,000 1 ≤ L ≤ 50,000
1 ≤ N ≤ 250
Example:
Input:
130 340 5
10 50
130 130
70 170
0 180
60 260
Output:
Question: - 3
For example: the result of the insertion of a number 4 to the list [1, 2, 1] is the list [1, 2, 1, 4]. If we
delete the number 1 from this list, we get the list [2, 1, 4], but if we delete the number 3 from the list
[1, 2, 1, 4], the list stays unchanged.
The list is homogeneous if it contains at least two equal numbers and the list is heterogeneous if
it contains at least two different numbers. For example: the list [2, 2] is homogeneous, the list [2, 1,
4] is heterogeneous, the list [1, 2, 1, 4] is both, and the empty list is neither homogeneous nor
heterogeneous.
Write a program that handles a number of the operations insert and delete on the empty list
and determines list’s homogeneity and heterogeneity after each operation.
Input
The first line of the input file contains an integer number n — the number of operations to handle (1
≤ n ≤ 100 000).
Following n lines contain one operation description each. The operation description consists of a
word “insert” or “delete”, followed by an integer number k — the operation argument (−10^9 ≤ k ≤
10^9 ).
Output
For each operation output a line, containing a single word, describing the state of the list after
the operation:
Example:
Input:
11
insert 1
insert 2
insert 1
insert 4
delete 1
delete 3
delete 2
delete 1
insert 4
delete 4
delete 4
Output:
neither
hetero
both
both
hetero
hetero
hetero
neither
homo
neither
neither
Question: - 4
Pebble is a popular turn-based multi-player game played by kids. In this game, all the players are
given a binary string (i.e., a string consisting only of 0's and 1's) of some fixed length. The goal of the
game is to convert this binary string to a string containing all 0's.
In a turn, a player is allowed to perform only one operation:- Replace a 1 by a 0 or vice-versa. But
each such operation will flip the states of all the bits following the bit you changed.
Take for example, the string: 1001010. You decide to flip the 1 located at the 4th position. The new
string after the operation will be : 1000101. (Note that 5th to 7th bits flipped as a result of flipping
the 4th bit.)
Your small sister loves to play this game very much. So, you decide to gift her the pebble-solver
software which solves this game with the minimum number of operations(how else will you make
sure that she always wins?!). And we want to make sure that your software doesn't have any bugs.
(he he)
Input
There are going to multiple test cases. Each test case consists of a single line which is the initial bit-
string.
Output
Example:
Input:
0101
10000
00
Output:
Game #1: 3
Game #2: 2
Game #3: 0
Question: - 5
Albert, Charles and Mary invented a new version of the classical game Bingo. In traditional Bingo the
game is presided over by a non-player known as the caller. At the beginning of the game each player
is given a card containing a unique combination of numbers from 0 to N arranged in columns and
rows. The caller has a bag containing N + 1 balls, numbered from 0 to N. On each turn, the caller
randomly selects a ball from the bag, announces the number of the drawn ball to the players, and
sets the ball aside so that it cannot be selected again. Each player searches his card for the called
number and marks it if he finds it. The first player who marks a complete pre-announced pattern on
the card (for example, a full horizontal line) wins a prize.
In the Albert-Charles-Mary version, on each turn, the caller draws a first ball, returns it to the bag,
draws a second ball, returns it to the bag, and then calls out the absolute difference between the two
ball numbers. To generate even more excitement, before the game started a possibly empty subset
of balls is removed from the bag, in such a way that at least two balls remain there. They would like
to know if every number from 0 to N may still be called out with the new drawing method considering
the balls that were left in the bag.
Input
Each test case is given using exactly two lines. The first line contains two integers N and B. The
meaning of N was described above (1 ≤ N ≤ 90), while B represents the number of balls which
remained in the bag (2 ≤ B ≤ N + 1). The second line contains B distinct integers bi, indicating the
balls which remained in the bag (0 ≤ bi ≤ N). The last test case is followed by a line containing two
zeros.
Output
For each test case output a single line containing a single uppercase ‘Y’ if is possible to call out every
number from 0 to N, inclusive, or a single uppercase ‘N’ otherwise.
Example:
Input:
67
2134065
54
5301
53
150
00
Output:
Y
Y
N