-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19452a6
commit 88e6ef4
Showing
5 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import heapq | ||
import sys | ||
|
||
murderers_count = dict() | ||
victims = set() | ||
sorted_murderes = [] | ||
|
||
for line in sys.stdin: | ||
murderer, victim = line.split() | ||
|
||
victims.update([victim]) | ||
if murderer not in murderers_count: | ||
heapq.heappush(sorted_murderes, murderer) | ||
|
||
if murderer not in victims: | ||
muderer_count = murderers_count.setdefault(murderer, 0) | ||
murderers_count[murderer] = muderer_count + 1 | ||
|
||
if victim in murderers_count: | ||
del murderers_count[victim] | ||
|
||
print('HALL OF MURDERERS') | ||
while sorted_murderes: | ||
murderer = heapq.heappop(sorted_murderes) | ||
if murderer in murderers_count: | ||
print(f'{murderer} {murderers_count[murderer]}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Renly Varys | ||
Loras Khal | ||
Benjen Viserys | ||
Syrio Petyr | ||
Walder Syrio | ||
Jon Daenerys | ||
Brynden Joffrey | ||
Loras Daenerys | ||
Robb Shae | ||
Davos Samwell | ||
Khal Davos | ||
Shae Roose | ||
Tyrion Robert | ||
Margaery Sandor | ||
Edmure Sansa | ||
Jon Shae | ||
Jon Missandei | ||
Brynden Ros | ||
Edmure Samwell | ||
Walder Robin | ||
Mance Benjen | ||
Yara Jon | ||
Bronn Khal | ||
Ramsay Beric | ||
Sandor Yoren | ||
Mance Sandor | ||
Osha Joffrey | ||
Jorah Tyrion | ||
Jorah Edmure | ||
Shae Brynden | ||
Edmure Shae | ||
Joffrey Varys | ||
Davos Robin | ||
Edmure Tyrion | ||
Samwell Davos | ||
Cersei Tywin | ||
Sansa Beric | ||
Robin Eddard | ||
Joffrey Tywin | ||
Shae Roose | ||
Lysa Syrio | ||
Shae Eddard | ||
Davos Shae | ||
Beric Jon | ||
Gendry Robert | ||
Ramsay Tywin | ||
Osha Tywin | ||
Khal Roose | ||
Samwell Ygritte | ||
Jorah Bronn | ||
Shae Samwell | ||
Khal Shae | ||
Melisandre Ramsay | ||
Sansa Eddard | ||
Olenna Edmure | ||
Beric Olenna | ||
Jon Brienneof | ||
Tywin Loras | ||
Ygritte Stannis | ||
Walder Daenerys | ||
Arya Gendry | ||
Syrio Beric | ||
Eddard Syrio | ||
Joffrey Eddard | ||
Walder Cersei | ||
Jon Tyrion | ||
Ros Petyr | ||
Olenna Cersei | ||
Petyr Cersei | ||
Arya Syrio | ||
Renly Khal | ||
Yara Edmure | ||
Ramsay Viserys | ||
Bronn Benjen | ||
Varys Walder | ||
Talisa Tyrion | ||
Renly Samwell | ||
Robb Joffrey | ||
Sandor Talisa | ||
Jorah Jon | ||
Davos Robin | ||
Lysa Syrio | ||
Missandei Joffrey | ||
Beric Daenerys | ||
Yara Missandei | ||
Roose Sandor | ||
Arya Lysa | ||
Varys Tywin | ||
Melisandre Theon | ||
Walder Daenerys | ||
Samwell Mance | ||
Jorah Robin | ||
Yoren Shae | ||
Brienneof Eddard | ||
Sansa Robin | ||
Mance Renly | ||
Renly Sandor | ||
Ramsay Mance | ||
Beric Ros | ||
Jorah Robin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HALL OF MURDERERS | ||
Arya 3 | ||
Jorah 6 | ||
Margaery 1 | ||
Melisandre 2 | ||
Osha 2 | ||
Robb 2 | ||
Yara 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
https://judge.beecrowd.com/en/problems/view/1861 | ||
|
||
# Hall of Murderers | ||
|
||
Who killed Meryn Trant? Who killed Syrio Forel, in the case wherein he is | ||
actually dead? Who killed Stannis Baratheon? Who killed Myrcella Baratheon? Who | ||
killed Aerys II Targaryen? Who is going to kill (**spoiler alert!**) Jaime | ||
Lannister? For some of these questions we had the answer already. For others, we | ||
had just speculations. However, we have received from an anonymous correspondent | ||
a list describing many murders, which have already happened or are still to | ||
happen, revealing the name of the murderers as of the murdered ones. But the | ||
murders are not in lexicographical order, not even in chronological order, and | ||
it becomes hard to count how many people each murderer has killed. Can you help | ||
us? | ||
|
||
## Input | ||
|
||
Each line of input describes a murder by informing the murderer's name followed | ||
by the name of the one who has been killed. Each name consists of at least one | ||
and at most 10 characters, with the first being always in capital case and the | ||
others always in small case. The input consists of at least one and at most | ||
$10^5$ lines and is ended in end-of-file. | ||
|
||
## Output | ||
|
||
The first line of output shall be consisted of the sentence “HALL OF MURDERERS”, | ||
without the quotation marks. Each one of the following lines shall contain a | ||
name of a murderer followed by the number of people that he or she has killed. | ||
The list of murderers shall follow the lexicographical ordering. If a murderer | ||
has also ended up being killed, he or she shall not appear in the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data structures and libraries |