import sys
def mapi(c):
if c=='R':
return 1
elif c=='F':
return -1
return 0
def mapc(c):
if c=='R':
return '/'
elif c=='F':
return '\\'
return '_'
cout=sys.stdout
def Main():
t=int(input())
cs=1
while t>0:
cout.write("Case #%d:\n"%cs)
cs+=1
t-=1
s=input()
n=len(s)
h=[None]*(len(s)+1)
h[0]=0
for i in range(1,n+1):
h[i]=h[i-1]+mapi(s[i-1])
for i in range(n):
if s[i]=='F':
h[i]-=1
mn=min(h)
for i in range(n+1):
h[i]-=mn
mx=max(h[:n+1])
flag=0
for i in range(n):
if (s[i]=='C' or s[i]=='F') and h[i]==mx:
flag=1
if flag==0:
mx-=1
for i in range(mx,-1,-1):
tmp=""
tmp+='| '
for j in range(n):
if h[j]==i:
tmp+=mapc(s[j])
else:
tmp+=' '
tmp+=' '
cout.write(tmp.strip()+'\n')
cout.write('+'+'-'*(n+2)+'\n\n')
if __name__=="__main__":
Main()
def mapi(c):
if c=='R':
return 1
elif c=='F':
return -1
return 0
def mapc(c):
if c=='R':
return '/'
elif c=='F':
return '\\'
return '_'
cout=sys.stdout
def Main():
t=int(input())
cs=1
while t>0:
cout.write("Case #%d:\n"%cs)
cs+=1
t-=1
s=input()
n=len(s)
h=[None]*(len(s)+1)
h[0]=0
for i in range(1,n+1):
h[i]=h[i-1]+mapi(s[i-1])
for i in range(n):
if s[i]=='F':
h[i]-=1
mn=min(h)
for i in range(n+1):
h[i]-=mn
mx=max(h[:n+1])
flag=0
for i in range(n):
if (s[i]=='C' or s[i]=='F') and h[i]==mx:
flag=1
if flag==0:
mx-=1
for i in range(mx,-1,-1):
tmp=""
tmp+='| '
for j in range(n):
if h[j]==i:
tmp+=mapc(s[j])
else:
tmp+=' '
tmp+=' '
cout.write(tmp.strip()+'\n')
cout.write('+'+'-'*(n+2)+'\n\n')
if __name__=="__main__":
Main()
Comments
Post a Comment