Question 24 || Hacker Rank
Post Transition || Hacker Rank
We live in a
major country. This nation has towns_count in it. Every town has
some mail centers in which bundles are put away and moved.
Mail depots
have different internal design. In particular, every one of them has a few
limits on the bundles it can store - their weight ought to be between min_weight
and max_weight comprehensively, where min_weight
and max_weight are fixed for every office.
Bundles are
put away in some request in the workplace line. That implies, that they are
handled utilizing this request while sending and getting.
Once in a
while two mail centers, even in various towns, may sort out the accompanying
exchange: the first sends every one of its bundles to the subsequent one. The
subsequent one acknowledges the bundles that fulfill the weight condition for
the subsequent office and rejects any remaining ones. These dismissed bundles
return to the main office back and are put away in similar request they were
put away before they were sent. The acknowledged bundles move to the tail of
the subsequent office's line in similar request they were put away in the
primary office.
You ought to
deal with a few questions in your program. You'll be furnished with structures package,
post_office and town. to get done with this
responsibility, you ought to fill the accompanying capabilities:
Print_all_packages - given the town t,
print all bundles around here. They ought to be printed as follows:
Town_name:
0:
id_0
id_1
...
1:
id_2
id_3
...
...
where 0,
1 and so on are the quantities of mailing stations and id0,
id1 ... are the ids of bundles from the 0th
mail center in the request for its line id2, id3,
are from the 1st one and so on. There ought to be one '\t' image before
mail center numbers and two '\t' images before the ids.
send_all_acceptable_packages - given the towns source and target
mailing station records source_office_index and target_office_index,
deal with the exchange depicted above between the mail center #source_office_index
around source and the #target_office_index mailing station #town_with_most_packages
around .
find_town - considering all towns, track down
the one with the most number of bundles in all mail centers through and through
name. In the event that there are a few of them, track down the first
from the assortment .
Input
Arrangement
First line
of the information contains a solitary towns_count.towns_count number .
blocks follow, each portraying a town.
Each town
block contains a few lines. On the primary line there is a string town_name
- the name of the town. On the second line there is a whole number offices_count
- the quantity of the workplaces in the town. offices_count blocks
follow then, at that point, each depicting an office.
Each office
block likewise contains a few lines. On the principal line there are three
numbers isolated by single spaces: (the quantity of bundles in the workplace),
and (portrayed previously). blocks follow, each portraying a bundle.
Each bundle
block contains precisely two lines. On the main line there is a string which is
an id of the bundle. On the second line there is a number which is the
heaviness of the bundle.
Then, there
is a solitary number on the line which is the quantity of inquiries. blocks
follow, each depicting an inquiry.
Each inquiry
block contains a few lines. On the main line there is a whole number , or . In
the event that this number is , on the second line there is a string - the name
of town for which all bundles ought to be printed. In the event that this
number is , on the second line there are string , number , string and whole
number isolated by single spaces. That implies exchanges between mail center #
in the town and mail center # in the town ought to be handled.
On the off
chance that the number is , no lines follow and the town with the most number
of bundles ought to be found.
Requirements
Test Info
0
2
A
2
2 1 3
a 2
b 3
1 2 4
c 2
B
1
4 1 4
d 1
e 2
f 3
h 4
5
3
2 B 0 A 1
3
1 A
1 B
Test
Result 0
Town with
the most number of bundles is B
Town with
the most number of bundles is A
A:
0:
a
b
1:
c
e
f
h
B:
0:
d
Clarification
0
Before all
questions, town B has 4 bundles altogether, town A has 3 .
In any case, after exchange all bundles from B's th mail center go to the st
mailing station of A, with the exception of bundle d since it's excessively
light.
0 Comments