You are on page 1of 8

In the Byteland

f count of each
In the Byteland
Your task is to
.

country a string "S" is said to super ascii string if and only i


character in the string is equal to its ascii value.
country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26.
find out whether the given string is a super ascii string or not

Input Format:
First line contains number of test cases T, followed by T lines, each containing
a string "S".
Output Format:
For each test case print "Yes" if the String "S" is super ascii, else print "No"
Constraints:
1<=T<=100
1<=|S|<=400, S will contains only lower case alphabets ('a'-'z').
Sample Input and Output
SNo.
1
2
bba
scca

Input

Output

Yes
No

Explanation:
In case 1, viz. String "bba" The count of character 'b' is 2. Ascii value of 'b' is also 2.
The count of character 'a' is 1. Ascii value of 'a' is also 1.
Hence string "bba" is super ascii.
Note:
Please do not use package and namespace in your code. For object oriented langua
ges your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from <c
onio.h> / <process.h> as these files do not exist in gcc
Note:
For C and C++, return type of main() function should be int.

Zoya has developed a new game called Zombie World. The objective of the game is
to kill all zombies in given amount of time. More formally,

N represents the total number of zombies in the current level

T represents the maximum time allowed for the current level

P represents the initial energy level a player starts with

Ei defines the energy of the i-th zombie

vel

D defines the minimum energy the player needs, to advance to the next le

In order to defeat a zombie, player energy must be at least equal to the i-th zo
mbie's energy. If the player succeeded in defeating the zombie, then he will be
awarded with an additional energy equal to the difference between current zombie
energy and the player energy.
One unit of time will be taken to complete the fight with a single zombie.
Rules of the game:

At any given time, a player can fight with only one zombie

Player is allowed to choose any one zombie to fight with.

Your task is to determine whether the player will advance to the next level or n
ot, if he plays optimally.
Input Format:
The first line contains the number of test cases (K)
Each test case consists of three parts:
1. The total number of zombies (N) and the maximum time allowed (T)
2. Array of size N, which represents the energy of zombies (E)
3. The initial energy level a player (P) and the minimum energy required to adva
nce (D)
Output Format:
Print "Yes" if a player can advance to the next level else print "No".
Constraints:

1<=K<=10
1<=N<=50
1<=Ei<=500
1<=T<=100
1<=D<=2000
1<=P<=500
Sample Input and Output
SNo.
1
1
2 3
4 5
5 7

Input

Output

Yes

Note:
Please do not use package and namespace in your code. For object oriented langua
ges your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from <c
onio.h> / <process.h> as these files do not exist in gcc
Note:
For C and C++, return type of main() function should be int.

Given a square maze (A) of dimension N, every entry (Aij) in the maze is either
an open cell 'O' or a wall 'X'. A rat can travel to its adjacent locations (left
, right, top and bottom), but to reach a cell, it must be open. Given the locati
ons of R rats, can you find out whether all the rats can reach others or not.
Input Format:
Input will consist of three parts, viz.

1.
2.
3.
4.

Size of the maze (N)


The maze itself (A = N * N)
Number of rats (R)
Location of R rats (Xi, Yi)

Note:
(Xi,Yi) will represents the location of the i-th rat.
Locations are 1-index based.
Output Format:
Print "Yes" if the rats can reach each other, else print "No"
Constraints:
1<=N<=350
Aij = {'O','X'}
1<=X<=N*N
1<=Xi<=N
1<=Yi<=N
Sample Input and Output
SNo.
1
3
O O X
O X O
O O X
4
1 1
1 2
2 1
3 2
Yes
2
3
O
O
O
4
1
1
2
2

O X
X O
O X
1
2
1
3

No

Note:

Input

Output

Please do not use package and namespace in your code. For object oriented langua
ges your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from <c
onio.h> / <process.h> as these files do not exist in gcc
Note:
For C and C++, return type of main() function should be int.

In a social network, online communities refer to the group of people with an int
erest towards the same topic.
People connect with each other in a social network. A connection between Person
I and Person J is represented as C I J. When two persons belonging to different
communities connect, the net effect is merger of both communities which I and J
belonged to.
We are only interested in finding out the communities with the member count bein
g an even number. Your task is to find out those communities.
Input Format:
First line starts with N, and then each
tion between two people or represents a
wo people it will be represented by C I
ected to each other. In case of a query
-1 will represents the end of input.

line of input either represents a connec


query. In case of a connection between t
J, which will represent I and J are conn
it will be represented by Q.

Input will consist of three parts, viz.


1. The total number of people on the social network (N)
2.Queries
C I J, connect I and J
Q 0 0, print the number of communities with even member-count
-1 will represent end of input.
Output Format:
For each query Q, output the number of communities with even member-count

Constraints:
1<=N<=1000000
1<=I, J<=N
Sample Input and Output
SNo.
1
5
Q 0 0
C 1 2
Q 0 0
C 2 3
Q 0 0
C 4 5
Q 0 0
-1

Input

Output

0
1
0
1

Explanation:
For first query there are no members in any of the groups hence answer is 0. Aft
er C 1 2, there is a group (let's take it as G1) with 1 and 2 as members hence t
otal count at this moment is 1. After C 2 3 total members in G1 will become {1,
2, 3} hence there are no groups with even count. After C 4 5 there formed a new
group G2 with {4, 5} as members, hence the total groups with even count is 1.
Note:
Please do not use package and namespace in your code. For object oriented langua
ges your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from <c
onio.h> / <process.h> as these files do not exist in gcc
Note:
For C and C++, return type of main() function should be

Raj is a newbie to the programming and while learning the programming language h
e came to know the following rules:

Each program must start with '{' and end with '}'.

Each program must contain only one main function. Main function must sta
rt with '<' and end with '>'.

A program may or may not contain user defined function(s). There is no l


imitation on the number of user defined functions in the program. User defined f
unction must start with '(' and end with ')'.

Loops are allowed only inside the functions (this function can be either
main function or user defined function(s)). Every loop must start with '{' and
end with '}'.

User defined function(s) are not allowed to be defined inside main funct
ion or other user defined function(s).

Nested loops are allowed.

Instructions can be anywhere inside the program.

Number of instructions inside any user defined function must not be more
than 100.

If any of the above conditions is not satisfied, then the program will generate
compilation errors. Today Raj has written a few programs, but he is not sure abo
ut the correctness of the programs. Your task is to help him to find out whether
his program will compile without any errors or not.
Input Format:
First line starts with T, number of test cases. Each test case will contain a si
ngle line L, where L is a program written by Raj.
Output Format:
Print "No Compilation Errors" if there are no compilation errors, else print "Co
mpilation Errors".
Constraints:
1<=T<=100
L is a text and can be composed of any of the characters {, }, (, ), <, >and P,
where P will represents the instruction.
L, comprised of characters mentioned above should be single spaced delimited.
Number of characters in the text, |L| < = 10000
Sample Input and Output

SNo.
Input Output
1
3
{ < > ( P ) }
{ < { } > ( { } ) )
{ ( { } ) }
No Compilation Errors
Compilation Errors
Compilation Errors

Note:
Please do not use package and namespace in your code. For object oriented langua
ges your code should be written in one class.
Note:
Participants submitting solutions in C language should not use functions from <c
onio.h> / <process.h> as these files do not exist in gcc
Note:
For C and C++, return type of main() function should be int.

You might also like