Created
April 13, 2014 10:35
-
-
Save Nabb/10578366 to your computer and use it in GitHub Desktop.
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
for case in range(input()): | |
print "Case #%d:" % (case+1) | |
r,c,m = map(int, raw_input().split()) | |
flip = r>c | |
if flip: c,r = r,c | |
rem = r*c-m | |
if r==1 or rem==1: | |
res = () | |
elif r>1 and rem in {2,3,5,7} or (r==2 and rem%2): | |
print "Impossible" | |
continue | |
elif rem <= 2*c+1: | |
res = (rem//2-rem%2,)*2 | |
else: | |
res = (c,)*(rem//c-1) + (c-(rem%c==1),) | |
res = (res + (rem-sum(res),) + (0,)*r)[:r] | |
board = ["."*res[i]+"*"*(c-res[i]) for i in range(r)] | |
board[0] = "c" + board[0][1:] | |
if flip: board = zip(*board) | |
for row in board: print "".join(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment