Submission #3435295


Source Code Expand

s = input()
x, y = map(int, input().split())

x_list = []
y_list = []

f = 0
t = 0
for i in s:
    if i == "F":
        f += 1
    else:
        t += 1
        if t % 2 == 1:
            x_list.append(f)
            f = 0
        else:
            y_list.append(f)
            f = 0
if f > 0:
    if t % 2 == 0:
        x_list.append(f)
    else:
        y_list.append(f)

dpx = [[0 for i in range(16001)] for j in range(len(x_list)+1)]
dpy = [[0 for i in range(16001)] for j in range(len(y_list)+1)]

dpx[0][8000] = 1
dpy[0][8000] = 1

for i in range(len(x_list)):
    for num in range(16001):
        if num + x_list[i] <= 16000 and dpx[i][num] == 1:
            dpx[i+1][num+x_list[i]] = 1
        if num - x_list[i] >= 0 and dpx[i][num] == 1:
            dpx[i+1][num-x_list[i]] = 1

for i in range(len(y_list)):
    for num in range(16001):
        if num + y_list[i] <= 16000 and dpy[i][num] == 1:
            dpy[i+1][num+y_list[i]] = 1
        if num - y_list[i] >= 0 and dpy[i][num] == 1:
            dpy[i+1][num-y_list[i]] = 1

if dpx[len(x_list)][x+8000] == 1 and dpy[len(y_list)][y+8000] == 1:
    print("Yes")
else:
    print("No")

Submission Info

Submission Time
Task D - FT Robot
User mizukurage
Language Python (3.4.3)
Score 0
Code Size 1195 Byte
Status WA
Exec Time 2132 ms
Memory 445172 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 6
AC × 15
WA × 1
TLE × 40
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 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 AC 41 ms 3700 KB
0_01.txt AC 43 ms 3700 KB
0_02.txt AC 26 ms 3444 KB
0_03.txt AC 33 ms 3572 KB
0_04.txt AC 41 ms 3700 KB
0_05.txt AC 51 ms 3828 KB
1_00.txt AC 25 ms 3572 KB
1_01.txt WA 26 ms 3572 KB
1_02.txt AC 33 ms 3700 KB
1_03.txt AC 33 ms 3572 KB
1_04.txt AC 43 ms 3828 KB
1_05.txt AC 41 ms 3700 KB
1_06.txt TLE 2131 ms 443508 KB
1_07.txt TLE 2131 ms 444660 KB
1_08.txt TLE 2130 ms 429812 KB
1_09.txt TLE 2131 ms 442484 KB
1_10.txt TLE 2130 ms 440636 KB
1_11.txt TLE 2132 ms 442612 KB
1_12.txt TLE 2125 ms 346228 KB
1_13.txt TLE 2125 ms 346228 KB
1_14.txt TLE 2130 ms 444444 KB
1_15.txt TLE 2131 ms 442612 KB
1_16.txt TLE 2132 ms 444660 KB
1_17.txt TLE 2130 ms 435444 KB
1_18.txt TLE 2131 ms 442612 KB
1_19.txt TLE 2130 ms 440784 KB
1_20.txt TLE 2131 ms 442612 KB
1_21.txt TLE 2131 ms 443252 KB
1_22.txt TLE 2131 ms 444660 KB
1_23.txt TLE 2130 ms 443932 KB
1_24.txt TLE 2130 ms 424052 KB
1_25.txt TLE 2131 ms 444660 KB
1_26.txt TLE 2131 ms 445172 KB
1_27.txt TLE 2131 ms 445172 KB
1_28.txt TLE 2130 ms 442860 KB
1_29.txt TLE 2130 ms 431348 KB
1_30.txt TLE 2120 ms 263284 KB
1_31.txt TLE 2118 ms 246772 KB
1_32.txt TLE 2111 ms 137760 KB
1_33.txt TLE 2112 ms 129780 KB
1_34.txt TLE 2108 ms 66420 KB
1_35.txt TLE 2107 ms 62068 KB
1_36.txt TLE 2106 ms 36084 KB
1_37.txt TLE 2106 ms 44276 KB
1_38.txt AC 1041 ms 18932 KB
1_39.txt AC 1326 ms 20724 KB
1_40.txt AC 510 ms 10996 KB
1_41.txt AC 636 ms 12532 KB
1_42.txt TLE 2125 ms 348788 KB
1_43.txt TLE 2124 ms 348496 KB
1_44.txt TLE 2125 ms 348532 KB
1_45.txt TLE 2125 ms 347764 KB
1_46.txt TLE 2125 ms 347892 KB
1_47.txt TLE 2124 ms 348616 KB
1_48.txt TLE 2126 ms 348404 KB
1_49.txt TLE 2129 ms 347636 KB