import sys
def main():
def getteam(a):
if int(a)<=3:
return 1
return 0
def get_home(a):
if int(a)<=3:
return "7"
return "8"
maze={str(item+1):{"D":0,"G":0,"F":0} for item in range(8) }
for x in (sys.stdin.readlines()):
if len(x)>1:
item=x.strip().split()
if int(item[0])==1:
maze[item[1]][item[2]]+=int(item[3])
elif int(item[0])==2:
for x in ["D","G","F"]:
maze[item[1]][x]+=maze[item[2]][x]
maze[item[2]][x]=0
elif int(item[0])==3:
maze[item[1]][item[2]]+=int(item[3])
maze[(get_home(7-int(item[1])))][item[2]]-=int(item[3])
elif int(item[0])==4:
maze[(get_home(item[1]))][item[2]]+=int(item[3])
maze[item[1]][item[2]]-=int(item[3])
elif int(item[0])==5:
maze[str(get_home(item[1]))][item[2]]+=maze[(item[1])][item[2]]//2
maze[(item[1])][item[2]]=maze[(item[1])][item[2]]//2
else:
a+=1
red_people_score =10*sum([maze[str(item+1)]["D"] for item in range(3)])+5*sum([maze[str(item+1)]["G"] for item in range(3)])+1*sum([maze[str(item+1)]["F"] for item in range(3)])
blue_people_score=10*sum([maze[str(item+4)]["D"] for item in range(3)])+5*sum([maze[str(item+4)]["G"] for item in range(3)])+1*sum([maze[str(item+4)]["F"] for item in range(3)])
red_home_score=20*maze["7"]["D"] +10*maze["7"]["G"] +2*maze["7"]["F"]
blue_home_score=20*maze["8"]["D"] +10*maze["8"]["G"] +2*maze["8"]["F"]
print(f"{int(red_people_score+red_home_score)} {int(blue_people_score+blue_home_score)}")
main()
92%解
import sys
def main():
def getteam(a):
if int(a)<=3:
return 1
return 0
def get_home(a):
if int(a)<=3:
return "7"
return "8"
maze={str(item+1):{"D":0,"G":0,"F":0} for item in range(8) }
for x in (sys.stdin.readlines()):
if len(x)>1:
item=x.strip().split()
if int(item[0])==1:
maze[item[1]][item[2]]+=int(item[3])
elif int(item[0])==2:
for x in ["D","G","F"]:
maze[item[1]][x]+=maze[item[2]][x]
maze[item[2]][x]=0
elif int(item[0])==3:
maze[item[1]][item[2]]+=int(item[3])
maze[(get_home(7-int(item[1])))][item[2]]-=int(item[3])
elif int(item[0])==4:
maze[(get_home(item[1]))][item[2]]+=int(item[3])
maze[item[1]][item[2]]-=int(item[3])
elif int(item[0])==5:
maze[str(get_home(item[1]))][item[2]]+=maze[(item[1])][item[2]]//2
maze[(item[1])][item[2]]=maze[(item[1])][item[2]]//2
else:
a+=1
red_people_score =10*sum([maze[str(item+1)]["D"] for item in range(3)])+5*sum([maze[str(item+1)]["G"] for item in range(3)])+1*sum([maze[str(item+1)]["F"] for item in range(3)])
blue_people_score=10*sum([maze[str(item+4)]["D"] for item in range(3)])+5*sum([maze[str(item+4)]["G"] for item in range(3)])+1*sum([maze[str(item+4)]["F"] for item in range(3)])
red_home_score=20*maze["7"]["D"] +10*maze["7"]["G"] +2*maze["7"]["F"]
blue_home_score=20*maze["8"]["D"] +10*maze["8"]["G"] +2*maze["8"]["F"]
print(f"{int(red_people_score+red_home_score)} {int(blue_people_score+blue_home_score)}")
main()92%解
import sys
def main():
def getteam(a):
if int(a)<=3:
return 1
return 0
def get_home(a):
if int(a)<=3:
return "7"
return "8"
maze={str(item+1):{"D":0,"G":0,"F":0} for item in range(8) }
for x in (sys.stdin.readlines()):
item=x.strip().split()
if int(item[0])==1:
maze[item[1]][item[2]]+=int(item[3])
elif int(item[0])==2:
for x in ["D","G","F"]:
maze[item[1]][x]+=maze[item[2]][x]
maze[item[2]][x]=0
elif int(item[0])==3:
maze[item[1]][item[2]]+=int(item[3])
maze[(get_home(7-int(item[1])))][item[2]]-=int(item[3])
elif int(item[0])==4:
maze[(get_home(item[1]))][item[2]]+=int(item[3])
maze[item[1]][item[2]]-=int(item[3])
elif int(item[0])==5:
maze[str(get_home(item[1]))][item[2]]+=maze[(item[1])][item[2]]//2
maze[(item[1])][item[2]]=maze[(item[1])][item[2]]//2
red_people_score =10*sum([maze[str(item+1)]["D"] for item in range(3)])+5*sum([maze[str(item+1)]["G"] for item in range(3)])+1*sum([maze[str(item+1)]["F"] for item in range(3)])
blue_people_score=10*sum([maze[str(item+4)]["D"] for item in range(3)])+5*sum([maze[str(item+4)]["G"] for item in range(3)])+1*sum([maze[str(item+4)]["F"] for item in range(3)])
red_home_score=20*maze["7"]["D"] +10*maze["7"]["G"] +2*maze["7"]["F"]
blue_home_score=20*maze["8"]["D"] +10*maze["8"]["G"] +2*maze["8"]["F"]
print(f"{int(red_people_score+red_home_score)} {int(blue_people_score+blue_home_score)}")
main()
刪除不必要的程式後還是92%
有人可以修正嗎(目前好像沒有人使用PYTHON AC)