Input Format:: Problem: Super ASCII String Checker
Input Format:: Problem: Super ASCII String Checker
In the Byteland country a string "S" is said to super ascii string if and only if count of each
character in the string is equal to its ascii value.
Your task is to 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').
2
1 Yes
bba
No
scca
Explanation:
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
- D defines the minimum energy the player needs, to advance to the next level
When a player energy is greater than or equal to the i-th zombie's energy, the player wins.
Upon winning, the player 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 not, if he plays
optimally.
Input Format:
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 advance (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
1
1 23
Yes
45
57
Problem : Stone Game - One Four
Alice and Bob are playing a game called "Stone Game". Stone game is a two-player game.
Let N be the total number of stones. In each turn, a player can remove either one stone or
four stones. The player who picks the last stone, wins. They follow the "Ladies First" norm.
Hence Alice is always the one to make the first move. Your task is to find out whether Alice
can win, if both play the game optimally.
Input Format:
First line starts with T, which is the number of test cases. Each test case will contain N
number of stones.
Output Format:
Constraints:
1<=T<=1000
1<=N<=10000
3
Yes
1 1
Yes
6
No
7
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 locations of Rrats, can you find out whether all
the rats can reach others or not?
Input Format:
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<=R<=N*N
1<=Xi<=N
1<=Yi<=N
3
OOX
OXO
OOX
1
4 Yes
11
12
21
32
3
OOX
OXO
OOX
2
4 No
11
12
21
23
Problem : Online Communities - Even Groups
In a social network, online communities refer to the group of people with an interest
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 being an
even number. Your task is to find out those communities.
Input Format:
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<=10^6
1<=I, J<=N
5 0
1 Q00 1
C12 0
Q00 1
C23
Q00
C45
Q00
-1
Explanation:
For first query there are no members in any of the groups hence answer is 0.
After C 1 2, there is a group (let's take it as G1) with 1 and 2 as members hence total 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.
You are given a square matrix of dimension N. Let this matrix be called A. Your task is to
rotate A in clockwise direction byS degrees, where S is angle of rotation. On the matrix,
there will be 3 types of operations viz.
1. Rotation
2. Querying
3. Updation
Update the element at row X and column Y with value Z, presented as input in form
of U X Y Z
Input Format:
Note:
Output Format:
For each Query operation print the element present at K-L location of the matrix in its
current state.
Constraints:
1<=N<=1000
1<=Aij<=1000
0<=S<=160000
1<=K, L<=N
1<=Q<=100000
2
12
34 3
1 A 90 1
Q11 4
Q12 6
A 90
Q11
U116
Q22
-1
Explanation:
Initial Matrix
12
34
31
42
Again the angle of rotation is 90 degree, now after the rotation the matrix will become
43
21
62
34
After updating, apply all the previous rotations (i.e. 180 = two 90 degree rotations).
43
26
Now A22 is 6.
Raj is a newbie to the programming and while learning the programming language he 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 start with '<' and
end with '>'.
- A program may or may not contain user defined function(s). There is no limitation on the
number of user defined functions in the program. User defined function 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 function or other user
defined function(s).
- 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 about 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 single line L,
where L is a program written by Raj.
Output Format:
Print "No Compilation Errors" if there are no compilation errors, else print "Compilation
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.
3
No Compilation Errors
1 {<>(P)}
Compilation Errors
{<{}>({}))
Compilation Errors
{({})}