Submission #24373628
Source Code Expand
from collections import deque
T=int(input())
for _ in range(T):
S=input()
L=len(S)
#DFS/BFS 非再帰
D=deque([])
keta,num=0,1
D.appendleft([keta,0,num])
D.append([keta,1,num])
#探索
while D:
keta,down,num=D.popleft()
if keta==L:
print(num)
break
ns=int(S[keta])+down*10
if num<=ns:
num_new=max(num,-(-ns//3))
D.appendleft([keta+1,0,num_new])
if num<=ns-1:
ns-=1
num_new=max(num,-(-ns//3))
D.append([keta+1,1,num_new])
Submission Info
| Submission Time | |
|---|---|
| Task | C - 1, 2, 3 - Decomposition |
| User | Pandruant |
| Language | Python (3.8.2) |
| Score | 600 |
| Code Size | 501 Byte |
| Status | AC |
| Exec Time | 343 ms |
| Memory | 9516 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01_sample_01.txt |
| All | 01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_N_01.txt, 03_rand_N_02.txt, 03_rand_N_03.txt, 03_rand_N_04.txt, 03_rand_N_05.txt, 03_rand_N_06.txt, 03_rand_N_07.txt, 03_rand_N_08.txt, 03_rand_N_09.txt, 03_rand_N_10.txt, 04_rand_ans_01.txt, 04_rand_ans_02.txt, 04_rand_ans_03.txt, 04_rand_ans_04.txt, 04_rand_ans_05.txt, 04_rand_ans_06.txt, 04_rand_ans_07.txt, 04_rand_ans_08.txt, 04_rand_ans_09.txt, 04_rand_ans_10.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01_sample_01.txt | AC | 33 ms | 9164 KiB |
| 02_small_01.txt | AC | 38 ms | 9160 KiB |
| 02_small_02.txt | AC | 40 ms | 9176 KiB |
| 02_small_03.txt | AC | 42 ms | 9316 KiB |
| 02_small_04.txt | AC | 40 ms | 9400 KiB |
| 02_small_05.txt | AC | 41 ms | 9336 KiB |
| 02_small_06.txt | AC | 42 ms | 9436 KiB |
| 02_small_07.txt | AC | 42 ms | 9308 KiB |
| 02_small_08.txt | AC | 41 ms | 9308 KiB |
| 02_small_09.txt | AC | 41 ms | 9308 KiB |
| 02_small_10.txt | AC | 40 ms | 9376 KiB |
| 03_rand_N_01.txt | AC | 333 ms | 9204 KiB |
| 03_rand_N_02.txt | AC | 332 ms | 9312 KiB |
| 03_rand_N_03.txt | AC | 343 ms | 9332 KiB |
| 03_rand_N_04.txt | AC | 314 ms | 9296 KiB |
| 03_rand_N_05.txt | AC | 331 ms | 9212 KiB |
| 03_rand_N_06.txt | AC | 310 ms | 9480 KiB |
| 03_rand_N_07.txt | AC | 343 ms | 9516 KiB |
| 03_rand_N_08.txt | AC | 325 ms | 9240 KiB |
| 03_rand_N_09.txt | AC | 333 ms | 9400 KiB |
| 03_rand_N_10.txt | AC | 335 ms | 9304 KiB |
| 04_rand_ans_01.txt | AC | 101 ms | 9332 KiB |
| 04_rand_ans_02.txt | AC | 96 ms | 9372 KiB |
| 04_rand_ans_03.txt | AC | 111 ms | 9444 KiB |
| 04_rand_ans_04.txt | AC | 94 ms | 9216 KiB |
| 04_rand_ans_05.txt | AC | 94 ms | 9240 KiB |
| 04_rand_ans_06.txt | AC | 109 ms | 9280 KiB |
| 04_rand_ans_07.txt | AC | 98 ms | 9456 KiB |
| 04_rand_ans_08.txt | AC | 98 ms | 9228 KiB |
| 04_rand_ans_09.txt | AC | 94 ms | 9232 KiB |
| 04_rand_ans_10.txt | AC | 107 ms | 9232 KiB |
| 05_handmade_01.txt | AC | 65 ms | 9448 KiB |
| 05_handmade_02.txt | AC | 54 ms | 9276 KiB |
| 05_handmade_03.txt | AC | 34 ms | 9272 KiB |