Name | Language | Tokens Sum | Tokens Part 1 | Tokens Part 2 | Last change | |
---|---|---|---|---|---|---|
1 | CornerMercury | Python | 194 | 97 | 97 | 41 days ago |
2 | dbasden | Python | 257 | 127 | 130 | 43 days ago |
3 | Szabolcs Dombi | Python | 263 | 105 | 158 | 43 days ago |
4 | Mechazawa | JavaScript | 10121 | 121 | - | 43 days ago |
import
sys
,
graphlib
partial_orderings
=
[
]
for
l
in
map
(
str
.
strip
,
sys
.
stdin
)
:
if
not
l
:
break
partial_orderings
.
append
(
l
.
split
(
'
|
'
)
)
part2
=
0
for
l
in
map
(
str
.
strip
,
sys
.
stdin
)
:
pagelist
=
l
.
split
(
'
,
'
)
ts
=
list
(
graphlib
.
TopologicalSorter
(
{
b
:
[
a
for
a
,
bb
in
partial_orderings
if
b
==
bb
and
a
in
pagelist
]
for
b
in
pagelist
}
)
.
static_order
(
)
)
part2
+=
int
(
ts
[
len
(
pagelist
)
//
2
]
)
*
(
ts
!=
pagelist
)
print
(
part2
)