-
Notifications
You must be signed in to change notification settings - Fork 6
/
contest_environment.py
25 lines (23 loc) · 835 Bytes
/
contest_environment.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
# Copyright (c) 2019 kamyu. All rights reserved.
#
# Facebook Hacker Cup 2018 Final Round - Contest Environment
# https://www.facebook.com/hackercup/problem/1983047265329089/
#
# Time: O(N)
# Space: O(1)
#
def contest_environment():
F, B = raw_input().strip(), raw_input().strip()
if any(x == '#' for x in B):
return "Impossible"
unoccupied_count = sum(int(x == '.') for x in F) + sum(int(x == '.') for x in B)
max_blocked_count, blocked_count = 0, 0
for x in F:
if x == '#':
blocked_count += 1
else:
max_blocked_count = max(max_blocked_count, blocked_count)
blocked_count = 0
return "Possible" if (unoccupied_count - max_blocked_count >= 3) else "Impossible"
for case in xrange(input()):
print 'Case #%d: %s' % (case+1, contest_environment())