Sie sind auf Seite 1von 7

Problem : Alpha Numeric Sorting

Given text comprising of words and numbers, sort them both in ascending order and print
them in a manner that a word is followed by a number. Words can be in upper or lower
case. You have to convert them into lowercase and then sort and print them.
Input Format:

First line contains total number of test cases, denoted by N


Next N lines, each contains a text in which words are at odd position and numbers are at
even position and are delimited by space
Output Format:

Words and numbers sorted in ascending order and printed in a manner that a word is
followed by a number.
Constraints:
1. Text starts with a word
2. Count of words and numbers are the same.
3. Duplicate elements are not allowed
4. Words should be printed in lower case.
5. No special characters allowed in text.

Sample Input and Output

SNo. Input Output

2
1 ganesh 12 ramesh 19 sagar 35 sanjay 53
Sagar 35 sanjay 12 ganesH 53 ramesh 19
ganesh 19 lalit 26 rakesh 59 suresh 96
Ganesh 59 suresh 19 rakesh 26 laliT 96
Note:

Please do not use package and namespace in your code. For object oriented languages your
code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files
do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

Problem : MF Tracker

Mani is a savvy investor. He is reviewing his financial investment performance. He is


currently analyzing his investment into mutual funds he had made in the past. From those
funds he earned a certain amount each. Coincidentally, it so happened that all the funds
that Mani had invested in, had in turn invested the funds in same set of stocks. So when he
exited, he exited all Mutual Funds at the same time. Mani has past statements from each
Fund which tell him about the number of holdings of each stock and the value of the entire
portfolio when he exited those funds.

Mani is now curious to find out what was the price of each stock across all funds when he
exited. He wants to do this to find out if his decision to exit the funds based on today's price
was right or wrong. Your task is to help Mani find stock prices when he exited them.

Compute stock prices up to 11 decimal places and print them up to 2 decimal places.

Let's say all funds invested in TCS, Infy and Wipro, then Mani has the following knowledge

Fund 1 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Fund 2 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Fund 3 -> # of shares of TCS, Infy and Wipro each and overall value of Mani's portfolio
Input Format:

First line contains a single number N which denotes two things


1. Number of stocks in each mutual fund
2. Number of funds is also same as N

Next N lines, each contain a tuple representing two things

1. The quantities of each of the N stocks in the fund, delimited by space


2. The value of the holdings in that fund

Refer Sample Input for better understanding

Output Format:

Print price of each stock, upto 2 decimal point, on one line (first one on first line, second one
on second line ... Nth one on Nth line). First stock is the one that comes first in the first
tuple. Second stock is the one that comes second in the first tuple. So on and so forth.

OR

Print "Unsolvable" if the values of individual stocks cannot be calculated.


Sample Input and Output

SNo. Input Output

3 2600.00
1
10 9 8 56900 2100.00
7 15 9 63200 1500.00
12 8 1 49500

3
2 10 9 8 56900
Unsolvable
20 18 16 113800
30 27 24 170700
Note:

Please do not use package and namespace in your code. For object oriented languages your
code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files
do not exist in gcc
Note:

For C and C++, return type of main() function should be int.


Problem : TestVita

TCS is working on a new project called "TestVita". There are N modules in the project. Each
module (i) has completion time denoted in number of hours (Hi) and may depend on other
modules. If Module x depends on Module y then one needs to complete y before x.

As Project manager, you are asked to deliver the project as early as possible.
Provide an estimation of amount of time required to complete the project.
Input Format:

First line contains T, number of test cases.

For each test case:


1. First line contains N, number of modules.
2. Next N lines, each contain:
o (i) Module ID
o (Hi) Number of hours it takes to complete the module
o (D) Set of module ids that i depends on - integers delimited by space.

Output Format:

Output the minimum number of hours required to deliver the project.


Constraints:
1. 1 <= T <= 10
2. 0 < N < 1000; number of modules
3. 0 < i <= N; module ID
4. 0 < Hi < 60; number of hours it takes to complete the module i
5. 0 <= |D| < N; number of dependencies
6. 0 < Dk <= N; module ID of dependencies
Sample Input and Output

SNo. Input Output

1
5
15
1
261 16
332
423
513

Explanation:

Module 2 depends on module 1, hence complete module 1 first

After completing module 1 we can complete module 2 and then module 3

Module 4 and 5 can be started simultaneously in parallel after module 3 is completed.

Hence the answer = 5 + 6 + 3 + 2 = 16


Note:

Please do not use package and namespace in your code. For object oriented languages your
code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files
do not exist in gcc
Note:

For C and C++, return type of main() function should be int.


Problem : ISL Schedule
The Indian Soccer League (ISL) is an annual football tournament.
The group stage of ISL features N teams playing against each other with following set of
rules:
1. N teams play against each other twice - once at Home and once Away
2. A team can play only one match per day
3. A team cannot play matches on consecutive days
4. A team cannot play more than two back to back Home or Away matches
5. Number of matches in a day has following constraints

o The match pattern that needs to be followed is -


 Day 1 has two matches and Day 2 has one match,
 Day 3 has two matches and Day 4 has one match and so on
o There can never be 3 or more matches in a day
6. Gap between two successive matches of a team cannot exceed floor(N/2)
days where floor is the mathematical function floor()
7. Derby Matches (any one)

o At least half of the derby matches should be on weekend


o At least half of the weekend matches should be derby matches
Your task is to generate a schedule abiding to above rules.

Input Format:

First line contains number of teams (N).


Next line contains state name of teams, delimited by space
Output Format:

Match format: Ta-vs-Tb


where Ta is the home team with id a and Tb is the away team with id b.
The final ascii string should contain all characters as in the provided input, at least once.
For each day print the match(es) in following format:-
 Two matches:- "#D Ta-vs-Tb Tm-vs-Tn"
 One match:- "#D Tx-vs-Ty"
where D is the day id and [a, b, m, n, x, y] are team ids.

Constraints:
1. 8 <= N <= 100
Note :

 Team ids are unique and have value between 1 to N


 Day id starts with 1
 Every 6th and 7th day are weekends
 Derby is a football match between two teams from the same state

Sample Input and Output

SNo. Input Output

#1 T1-vs-T6 T3-vs-T5
1 8
#2 T7-vs-T4
S1 S2 S5 S4 S3 S1 S6 S6
#3 ... and so on

Explanation:
There are 8 teams with following information:-
Team ID 1 2 3 4 5 6 7 8
State Name S1 S2 S5 S4 S3 S1 S6 S6

Problem : Romeo and Juliet

Romeo and Juliet stay in Rectanglevilla. As the name suggests, Rectanglevilla is indeed a
rectangle in shape. Romeo's current location is marked by 's'. Juliet's current location is
marked by 'd'. In a difficult hour, Romeo has to ensure that he reaches Juliet via the shortest
path and hence in shortest time.

There are many in Rectanglevilla who are enemies of Romeo and hence will not allow
Romeo to pass through their areas. Romeo must avoid these areas while reaching out for
Juliet. These areas are marked by 'w' character. Areas that Romeo can freely access is
marked by '-' character.

Today Romeo needs your help to reach Juliet via shortest path. Help him.

The input and output specification sections describe how inputs will be provided on console
and how output is expected back on console.
Input Format:
1. First line of input contains grid dimensions delimited by space character
2. Next rows number of lines contain column number of characters
3. Valid characters are {s, d, w, -}, where
a. s represents the location of the Romeo
b. d represents the location of the Juliet
c. w represents inaccessible region
d. - represents accessible region
4. End of input is marked by -1 character

Output Format:
1. Output grid should be of the same dimension as the input grid
2. Output grid should contain path from Romeo's location s to Juliet's location d
3. The 's' character in the grid must be replaced by character 'a' to denote that
Romeo is actively heading towards Juliet.
4. See example section for better understanding

Constraints:
1. It is guaranteed that there will always be exactly one shortest path for Romeo to reach
Juliet

Sample Input and Output


SNo. Input Output

44
w-d- w-d-
1 w-w- waw-
w-ww waww
s--- a---
-1

66
s----w a----w
----w- -a--w-
2 ---w-- --aw--
--w--- --wa--
-w---- -w--a-
w----d w----d
-1

Explanation for sample input and output 1:

Figure 1.

Note: - The output format shown above is for understanding purpose such that it highlights
the shortest path between Romeo and Juliet. The example in above table depicts output in
text format as you will be required to provide.
Note:

Please do not use package and namespace in your code. For object oriented languages your
code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files
do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

Das könnte Ihnen auch gefallen