-
Notifications
You must be signed in to change notification settings - Fork 21
/
g.py
25 lines (18 loc) · 902 Bytes
/
g.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def turtles_liars(statements):
previous_statements = set()
for statement in statements:
no_negative_placements = statement[0] >= 0 and statement[1] >= 0
correct_number_of_turtles = statement[0] + statement[1] + 1 == len(statements)
if no_negative_placements and correct_number_of_turtles and statement not in previous_statements:
previous_statements.add(statement)
return len(previous_statements)
assert turtles_liars([(1, 0), (1, 0)]) == 1
assert turtles_liars([(2, 0), (0, 2), (2, 2)]) == 2
assert turtles_liars([(0, 4), (1, 3), (2, 2), (3, 1), (4, 0)]) == 5
assert turtles_liars([(9, 1), (8, 1), (7, 2), (6, 2), (5, 3), (4, 4), (3, 6), (2, 7), (1, 9), (8, 0)]) == 4
def main():
n = int(input())
statements = [tuple(map(int, input().split())) for _ in range(n)]
print(turtles_liars(statements))
if __name__ == '__main__':
main()