Friends and ACM
Time Limit: 1.5 sec
The Problem
There are four close friends Moni, Rasel, Touhid and Ullash. They do everything together like going somewhere, reading for exam, watching movie etc. Although they are close friend, they do not want to share money with each other.
They have a bad habit. During exam, they read only on this time. So, they have to read more at night and they need more energy. Around 1 o’clock they go to nearest bazar formidnight breakfast. When they are going to bazar for breakfast, they don’t take money everybody. Only one of them take the money for safety for any accident because it is about 1:30am.
For calculating their cost they want to make a ACM(Automatic Computing Machine) machine. They want help from you to make this machine. Help them to make this.
ACM machine calculate every day’s bill for them. After some days it gives a result of who get money from whom and how much. See input, output, sample input and output for more clearance.
The Input
First line for test case T(1<=t<=100).
For each test start with the number of days n (1<=n<=1000). Following n lines contains M, R, T, U and S. M for moni’s bill, R for rasel’s bill, T for touhid’s bill, U for ullash’s bill and S for name who paid this bill.
M,R,T,U ( <=1000000 ).
S ( Moni/Rasel/Touhid/Ullas ).
The Output
For each case you have to print the case number and a matrix. Like
Case T:
MR MT MU
RM RT RU
TM TR TU
UM UR UT
MR-> How much money moni get from rasel. If no , then print ‘0‘. RM reverse of MR.
MT-> How much money moni get from touhid. If no , then print ‘0‘. TM reverse of MT.
MU-> How much money moni get from ullash. If no , then print ‘0‘. UM reverse of MU.
RT-> How much money rasel get from touhid. If no , then print ‘0‘. TR reverse of RT.
RU-> How much money rasel get from ullash. If no , then print ‘0‘. UR reverse of RU.
TU-> How much money touhid get from ullash. If no , then print ‘0‘. UT reverse of UT.
Sample Input
2
4
20 21 5 35 Rasel
50 30 15 40 Moni
10 20 6 25 Ullash
10 11 10 15 Touhid
2
10 20 30 40 Rasel
20 30 40 50 Rasel
Sample Output
Case 1:
10 5 30
0 0 15
0 6 9
0 0 0
Case 2:
0 0 0
30 70 90
0 0 0
0 0 0
Problem Setter: Monikrishna Roy [Jahangirnagar University]