Submission #3003713


Source Code Expand

Copy
import sys
s=input()
A,B =map(int,input().split())
t = 0
k=0
L=len(s)
table=[[] for i in range(2)]
for i in range(len(s)):
    if s[i]=='F':
        k+=1
    else:
        table[t].append(k)
        t=(t+1)%2
        k=0
table[t].append(k)
Lx=set()
Lx.add(table[0][0])
for i in range(1,len(table[0])):
    x=table[0][i]
    T=set()
    for a in Lx:
        if -L<=a+x<=L:
            T.add(a+x)
        if -L<=a-x<=L:
            T.add(a-x) 
    Lx=T
flag=True
for a in Lx:
    if a==A:
        flag =False
if flag:
    print('No')
    sys.exit()

Lx=set()
Lx.add(0)
for i in range(len(table[1])):
    x=table[1][i]
    T=set()
    for a in Lx:
        if -L<=a+x<=L:
            T.add(a+x)
        if -L<=a-x<=L:
            T.add(a-x) 
    Lx=T
flag=True
for a in Lx:
    if a==B:
        flag =False
if flag:
    print('No')
    sys.exit()
print('Yes')

Submission Info

Submission Time
Task D - FT Robot
User okumura
Language PyPy3 (2.4.0)
Score 500
Code Size 907 Byte
Status
Exec Time 428 ms
Memory 48732 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 500 / 500 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt
Case Name Status Exec Time Memory
0_00.txt 175 ms 38256 KB
0_01.txt 171 ms 38384 KB
0_02.txt 167 ms 38256 KB
0_03.txt 168 ms 38256 KB
0_04.txt 170 ms 38256 KB
0_05.txt 174 ms 38256 KB
1_00.txt 171 ms 38512 KB
1_01.txt 170 ms 38512 KB
1_02.txt 171 ms 38512 KB
1_03.txt 175 ms 38640 KB
1_04.txt 177 ms 38512 KB
1_05.txt 171 ms 38512 KB
1_06.txt 390 ms 48604 KB
1_07.txt 290 ms 44508 KB
1_08.txt 352 ms 47708 KB
1_09.txt 349 ms 46940 KB
1_10.txt 359 ms 47452 KB
1_11.txt 180 ms 39408 KB
1_12.txt 324 ms 42460 KB
1_13.txt 324 ms 42460 KB
1_14.txt 327 ms 45276 KB
1_15.txt 333 ms 45276 KB
1_16.txt 331 ms 44380 KB
1_17.txt 331 ms 44380 KB
1_18.txt 428 ms 47964 KB
1_19.txt 286 ms 43996 KB
1_20.txt 389 ms 48092 KB
1_21.txt 284 ms 43868 KB
1_22.txt 395 ms 48092 KB
1_23.txt 388 ms 47964 KB
1_24.txt 391 ms 47708 KB
1_25.txt 401 ms 48732 KB
1_26.txt 191 ms 39792 KB
1_27.txt 181 ms 39280 KB
1_28.txt 388 ms 48604 KB
1_29.txt 292 ms 43868 KB
1_30.txt 341 ms 46940 KB
1_31.txt 256 ms 43868 KB
1_32.txt 288 ms 46556 KB
1_33.txt 298 ms 47068 KB
1_34.txt 241 ms 43740 KB
1_35.txt 215 ms 41564 KB
1_36.txt 215 ms 41820 KB
1_37.txt 204 ms 40684 KB
1_38.txt 198 ms 39920 KB
1_39.txt 186 ms 39280 KB
1_40.txt 195 ms 40176 KB
1_41.txt 182 ms 39280 KB
1_42.txt 235 ms 41324 KB
1_43.txt 202 ms 41196 KB
1_44.txt 357 ms 48348 KB
1_45.txt 311 ms 42492 KB
1_46.txt 252 ms 41820 KB
1_47.txt 228 ms 41196 KB
1_48.txt 236 ms 41196 KB
1_49.txt 232 ms 41196 KB