Submission #1173746


Source Code Expand

import copy
temp=input().split()
H=int(temp[0])
W=int(temp[1])
K=int(temp[2])
T=int(temp[3])

AB=[]
CD=[]
for i in range(K):
	temp=input().split()
	AB.append([int(temp[0])-1,int(temp[1])-1])
	CD.append([int(temp[2])-1,int(temp[3])-1])
#inputEnd
existMap=[[False for j in range(W)] for i in range(H)]
nextExistMap=[[False for j in range(W)] for i in range(H)]
for i in range(K):
	existMap[AB[i][0]][AB[i][1]]=True
	nextExistMap[AB[i][0]][AB[i][1]]=True

ans=[]

roop=0
for k in range(15):
	while True:
		time=0
		tempAns="-"*(30*k)
		for i in range(30*k,30*(k+1)):
			if AB[i][0]<CD[i][0]:
				if existMap[AB[i][0]+1][AB[i][1]]==False and nextExistMap[AB[i][0]+1][AB[i][1]]==False:
					tempAns+="D"
					nextExistMap[AB[i][0]+1][AB[i][1]]=True
					nextExistMap[AB[i][0]][AB[i][1]]=False
					AB[i][0]+=1
					time+=1
					continue
			if AB[i][0]>CD[i][0]:
				if existMap[AB[i][0]-1][AB[i][1]]==False and nextExistMap[AB[i][0]-1][AB[i][1]]==False:
					tempAns+="U"
					nextExistMap[AB[i][0]-1][AB[i][1]]=True
					nextExistMap[AB[i][0]][AB[i][1]]=False
					AB[i][0]-=1
					time+=1
					continue
			if AB[i][1]<CD[i][1]:
				if existMap[AB[i][0]][AB[i][1]+1]==False and nextExistMap[AB[i][0]][AB[i][1]+1]==False:
					tempAns+="R"
					nextExistMap[AB[i][0]][AB[i][1]+1]=True
					nextExistMap[AB[i][0]][AB[i][1]]=False
					AB[i][1]+=1
					time+=1
					continue
			if AB[i][1]>CD[i][1]:
				if existMap[AB[i][0]][AB[i][1]-1]==False and nextExistMap[AB[i][0]][AB[i][1]-1]==False:
					tempAns+="L"
					nextExistMap[AB[i][0]][AB[i][1]-1]=True
					nextExistMap[AB[i][0]][AB[i][1]]=False
					AB[i][1]-=1
					time+=1
					continue
			tempAns+="-"
		if time==0 or roop==T:
			break
		else:
			tempAns+="-"*30*(14-k)
			ans.append(tempAns)
			roop+=1
			existMap=copy.deepcopy(nextExistMap)
	if roop==T:
		break


Length=len(ans)
print(Length)
for i in range(Length):
	print(ans[i])

Submission Info

Submission Time
Task B - 日本橋大渋滞
User toma25
Language Python (3.4.3)
Score 3280
Code Size 1960 Byte
Status AC
Exec Time 315 ms
Memory 4008 KB

Judge Result

Set Name test_01 test_02 test_03 test_04 test_05 test_06 test_07 test_08 test_09 test_10 test_11 test_12 test_13 test_14 test_15 test_16 test_17 test_18 test_19 test_20 test_21 test_22 test_23 test_24 test_25 test_26 test_27 test_28 test_29 test_30
Score / Max Score 113 / 50000 107 / 50000 112 / 50000 115 / 50000 121 / 50000 111 / 50000 109 / 50000 116 / 50000 102 / 50000 109 / 50000 115 / 50000 106 / 50000 109 / 50000 109 / 50000 107 / 50000 115 / 50000 109 / 50000 107 / 50000 109 / 50000 107 / 50000 114 / 50000 107 / 50000 111 / 50000 101 / 50000 105 / 50000 109 / 50000 109 / 50000 102 / 50000 107 / 50000 107 / 50000
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
test_01 subtask_01_01.txt
test_02 subtask_01_02.txt
test_03 subtask_01_03.txt
test_04 subtask_01_04.txt
test_05 subtask_01_05.txt
test_06 subtask_01_06.txt
test_07 subtask_01_07.txt
test_08 subtask_01_08.txt
test_09 subtask_01_09.txt
test_10 subtask_01_10.txt
test_11 subtask_01_11.txt
test_12 subtask_01_12.txt
test_13 subtask_01_13.txt
test_14 subtask_01_14.txt
test_15 subtask_01_15.txt
test_16 subtask_01_16.txt
test_17 subtask_01_17.txt
test_18 subtask_01_18.txt
test_19 subtask_01_19.txt
test_20 subtask_01_20.txt
test_21 subtask_01_21.txt
test_22 subtask_01_22.txt
test_23 subtask_01_23.txt
test_24 subtask_01_24.txt
test_25 subtask_01_25.txt
test_26 subtask_01_26.txt
test_27 subtask_01_27.txt
test_28 subtask_01_28.txt
test_29 subtask_01_29.txt
test_30 subtask_01_30.txt
Case Name Status Exec Time Memory
subtask_01_01.txt AC 315 ms 4008 KB
subtask_01_02.txt AC 174 ms 3880 KB
subtask_01_03.txt AC 177 ms 3880 KB
subtask_01_04.txt AC 176 ms 3880 KB
subtask_01_05.txt AC 184 ms 3880 KB
subtask_01_06.txt AC 170 ms 3880 KB
subtask_01_07.txt AC 173 ms 3880 KB
subtask_01_08.txt AC 158 ms 3752 KB
subtask_01_09.txt AC 179 ms 3880 KB
subtask_01_10.txt AC 146 ms 3752 KB
subtask_01_11.txt AC 183 ms 3880 KB
subtask_01_12.txt AC 175 ms 3880 KB
subtask_01_13.txt AC 157 ms 3752 KB
subtask_01_14.txt AC 174 ms 3880 KB
subtask_01_15.txt AC 147 ms 3752 KB
subtask_01_16.txt AC 164 ms 3752 KB
subtask_01_17.txt AC 156 ms 3752 KB
subtask_01_18.txt AC 181 ms 3880 KB
subtask_01_19.txt AC 166 ms 3752 KB
subtask_01_20.txt AC 187 ms 3880 KB
subtask_01_21.txt AC 169 ms 3752 KB
subtask_01_22.txt AC 169 ms 3752 KB
subtask_01_23.txt AC 148 ms 3752 KB
subtask_01_24.txt AC 214 ms 3880 KB
subtask_01_25.txt AC 168 ms 3752 KB
subtask_01_26.txt AC 183 ms 3880 KB
subtask_01_27.txt AC 163 ms 3752 KB
subtask_01_28.txt AC 161 ms 3752 KB
subtask_01_29.txt AC 183 ms 3880 KB
subtask_01_30.txt AC 170 ms 3880 KB