Problem:


Score : 500 points

Problem Statement

A robot is put at the origin in a two-dimensional plane.
Initially, the robot is facing in the positive x-axis direction.

This robot will be given an instruction sequence s.
s consists of the following two kinds of letters, and will be executed in order from front to back.

F : Move in the current direction by distance 1.

T : Turn 90 degrees, either clockwise or counterclockwise.

The objective of the robot is to be at coordinates (x, y) after all the instructions are executed.
Determine whether this objective is achievable.

Constraints

s consists of F and T.

1 \leq |s| \leq 8 000

x and y are integers.

|x|, |y| \leq |s|

Input

Input is given from Standard Input in the following format:

s
x y

Output

If the objective is achievable, print Yes; if it is not, print No.

Sample Input 1

FTFFTFFF
4 2

Sample Output 1

Yes

The objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.

Sample Input 2

FTFFTFFF
-2 -2

Sample Output 2

Yes

The objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.

Sample Input 3

FF
1 0

Sample Output 3

No

Sample Input 4

TF
1 0

Sample Output 4

No

Sample Input 5

FFTTFF
0 0

Sample Output 5

Yes

The objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.

Sample Input 6

TTTT
1 0

Sample Output 6

No



Sample input:
FTFFTFFF
4 2


Sample output:
Yes

Submission status: Wrong Answer

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

xlist = []
ylist = []
xory = 1 
xcount,ycount = 0,0 
for i in list(s):
    if i == "T":
        if xcount > 0:
            xlist.append(xcount)
            xcount = 0 
        elif ycount > 0:
            ylist.append(ycount)
            ycount = 0 
        xory = xory * -1
    elif xory == 1:
        xcount += 1
    elif xory == -1: 
        ycount += 1
xlist.append(xcount)
ylist.append(ycount)

def check(lis,hi):
    numlis = [lis[0]]
    for i in range(len(lis)-1):
        kari = numlis
        numlis = []
        for i2 in range(len(kari)):
            numlis.append(kari[i2]+lis[i+1])
            numlis.append(kari[i2]-lis[i+1])
    for i in numlis:
        if i == hi: 
            return True
    return False

if check(xlist,x) and check(ylist,y):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from itertools import groupby


S = input()
X, Y = map(int, input().split())


def check(A, x, start):
    S = set([start])
    for a in A:
        new_S = set([])
        for s in S:
            new_S.add(s + a)
            new_S.add(s - a)
        S = new_S
    # print(S)
    return x in S

groups = groupby(S)
tmp = True
A = []
B = []
start = None
which = None
for k, g in groups:
    if k == "T":
        if len(list(g)) % 2 != 0:
            tmp = not tmp
    else:
        if start is None:
            start = len(list(g))
            which = tmp
        else:
            if tmp:
                A.append(len(list(g)))
            else:
                B.append(len(list(g)))
# print(start, which, A, B)

if start is None:
    if X == 0 and Y == 0:
        print("Yes")
    else:
        print("No")
    exit()

if which:
    if check(A, X, start) and check(B, Y, 0):
        print("Yes")
    else:
        print("No")
else:
    if check(A, X, 0) and check(B, Y, start):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
 
order = input()
vector = np.array([1,0])
position = np.array([0,0])
goal = np.array([int(i) for i in input().rstrip().split()])
 
def r90deg(x):
    return x.dot([[0,-1],[1,0]])
    
def l90deg(x):
    return x.dot([[0,1],[-1,0]])
    

def judge(p,g,v):
    rp = p+r90deg(v)
    lp = p+l90deg(v)
    dr = g-rp
    dl = g-lp
    ar = abs(dr[0])+abs(dr[1])
    al = abs(dl[0])+abs(dl[1])
    
    if al >= ar:
        return r90deg(v)
    else:
        return l90deg(v)
    
 
for i in order:
    if i == 'F':
        position += vector
    elif i == 'T':
        vector = judge(position,goal,vector)
 
if (position[0] == goal[0]) and (position[1] == goal[1]) :
    print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np

order = input()
vector = np.array([1,0])
position = np.array([0,0])
goal = np.array([int(i) for i in input().rstrip().split()])

def r90deg(x):
    return x.dot([[0,-1],[1,0]])
    
def l90deg(x):
    return x.dot([[0,1],[-1,0]])
    
def oz(x,y):
    if (x!= 0 )and( x == y):
        return True
    else:
        return False
    
def judge(p,g,v):
    rp = p+r90deg(v)
    lp = p+l90deg(v)
    dr = g-rp
    dl = g-lp
    ar = abs(dr[0])+abs(dr[1])
    al = abs(dl[0])+abs(dl[1])
    
    if al > ar:
        return r90deg(v)
    else:
        return l90deg(v)
    

for i in order:
    if i == 'F':
        position += vector
    elif i == 'T':
        vector = judge(position,goal,vector)

if (position[0] == goal[0]) and (position[1] == goal[1]) :
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=list(input())
gx, gy=map(int,input().split(' '))
xmuki=1
ymuki=0
x=0
y=0
sax=int(gx)-int(x)
say=int(gy)-int(y)

for _ in s:
    sax=int(gx)-int(x)
    say=int(gy)-int(y)
    if _=='F' and xmuki==1:
        x =x+1
        continue
    elif _=='F' and xmuki==-1:
        x -=1
        continue
    elif _=='F' and ymuki==1:
        y +=1
        continue
    elif _=='F' and ymuki==-1:
        y -=1
        continue
    elif _=='T' and ymuki==0 and say>=0:
        ymuki=1
        xmuki=0
        continue
    elif _=='T' and ymuki==0 and say<0:
        ymuki=-1
        xmuki=0
        continue
    elif _=='T' and xmuki==0 and sax>=0:
        ymuki=0
        xmuki=1
        continue
    elif _=='T' and xmuki==0 and sax<0:
        ymuki=0
        xmuki=-1
        continue
    else:
        print('?')
        continue

sax=int(gx)-int(x)
say=int(gy)-int(y)

if sax==0 and say==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=list(input())
gx, gy=map(int,input().split(' '))
xmuki=1
ymuki=0
x=0
y=0
sax=int(gx)-int(x)
say=gy-y

for _ in s:
    sax=int(gx)-int(x)
    say=gy-y
    if _=='F' and xmuki==1:
        x =x+1
        continue
    elif _=='F' and xmuki==-1:
        x -=1
        continue
    elif _=='F' and ymuki==1:
        y +=1
        continue
    elif _=='F' and ymuki==-1:
        y -=1
        continue
    elif _=='T' and ymuki==0 and say>=0:
        ymuki=1
        xmuki=0
        continue
    elif _=='T' and ymuki==0 and say<0:
        ymuki=-1
        xmuki=0
        continue
    elif _=='T' and xmuki==0 and sax>=0:
        ymuki=0
        xmuki=1
        continue
    elif _=='T' and xmuki==0 and sax<0:
        ymuki=0
        xmuki=-1
        continue
    else:
        print('?')
        continue

sax=int(gx)-int(x)
say=gy-y

if sax==0 and say==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=list(input())
gx, gy=map(int,input().split(' '))
xmuki=1
ymuki=0
x=0
y=0
sax=int(gx)-int(x)
say=gy-y

for _ in s:
    if _=='F' and xmuki==1:
        x =x+1
        continue
    elif _=='F' and xmuki==-1:
        x -=1
        continue
    elif _=='F' and ymuki==1:
        y +=1
        continue
    elif _=='F' and ymuki==-1:
        y -=1
        continue
    elif _=='T' and ymuki==0 and say>=0:
        ymuki=1
        xmuki=0
        continue
    elif _=='T' and ymuki==0 and say<0:
        ymuki=-1
        xmuki=0
        continue
    elif _=='T' and xmuki==0 and sax>=0:
        ymuki=0
        xmuki=1
        continue
    elif _=='T' and xmuki==0 and sax<0:
        ymuki=0
        xmuki=-1
        continue
    else:
        print('?')
        continue

sax=int(gx)-int(x)
say=gy-y

if sax==0 and say==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=list(input())
gx, gy=map(int,input().split(' '))
xmuki=1
ymuki=0
x=0
y=0
sax=int(gx)-int(x)
say=gy-y

for _ in s:
    if _=='F' and xmuki==1:
        x =x+1
        continue
    elif _=='F' and xmuki==-1:
        x -=1
        continue
    elif _=='F' and ymuki==1:
        y +=1
        continue
    elif _=='F' and ymuki==-1:
        y -=1
        continue
    elif _=='T' and ymuki==0 and say>=0:
        ymuki=1
        xmuki=0
        continue
    elif _=='T' and ymuki==0 and say<0:
        ymuki=-1
        xmuki=0
        continue
    elif _=='T' and xmuki==0 and sax>=0:
        ymuki=0
        xmuki=1
        continue
    elif _=='T' and xmuki==0 and sax<0:
        ymuki=0
        xmuki=-1
        continue
    else:
        print('?')
        continue

sax=int(gx)-int(x)
say=gy-y

if sax==0 and say==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
x,y=map(int, input().split())
cnt = 0; mode = 2
l = len(s) # l + 1 + l
X = Y = 1 << l
for c in s:
    if c is 'F':
        cnt += 1
    else:
        if mode == 0:
            X |= (X >> cnt) | (X << cnt)
        elif mode == 1:
            Y |= (Y >> cnt) | (Y << cnt)
        else:
            X = X << cnt
            mode = 0
        cnt = 0; mode ^= 1
if cnt > 0:
    if mode == 0:
        X |= (X >> cnt) | (X << cnt)
    elif mode == 1:
        Y |= (Y >> cnt) | (Y << cnt)
    else:
        X = X << cnt
if (X >> (l + x)) & 1 and (Y >> (l + y)) & 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
x,y=map(int, input().split())
cnt = 0; mode = 2
l = len(s) # l + 1 + l
X = Y = 1 << l
for c in s:
    if c is 'F':
        cnt += 1
    else:
        if cnt > 0:
            if mode == 0:
                X |= (X >> cnt) | (X << cnt)
            elif mode == 1:
                Y |= (Y >> cnt) | (Y << cnt)
            else:
                X = X << cnt
                mode = 0
        cnt = 0; mode ^= 1
if cnt > 0:
    if mode == 0:
        X |= (X >> cnt) | (X << cnt)
    elif mode == 1:
        Y |= (Y >> cnt) | (Y << cnt)
    else:
        X = X << cnt
if (X >> (l + x)) & 1 and (Y >> (l + y)) & 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
y_lst = dir_lst[1]

can_x = False
can_y = False

s = set([0])
for x_ in x_lst:
    s_ = set()
    for e in s:
        s_.add(e+x_)
        s_.add(e-x_)
    s = s_
if x in s:
    can_x = True

s = set([0])
for y_ in y_lst:
    s_ = set()
    for e in s:
        s_.add(e+y_)
        s_.add(e-y_)
    s = s_
if y in s:
    can_y = True

if can_x and can_y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


# def part_sum0(a, A):
#     # 初期化
#     N = len(a)
#     dp = [[0 for i in range(A + 1)] for j in range(N + 1)]
#     dp[0][0] = 1
#
#     # DP
#     for i in range(N):
#         for j in range(A + 1):
#             if a[i] <= j:
#                 dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]
#             else:
#                 dp[i + 1][j] = dp[i][j]
#     return dp[N][A]

import sys
sys.setrecursionlimit(10**7)
def part_sum0(integer_list, target_sum,  i=0, sum_=0):
    if i == len(integer_list):
        return sum_ == target_sum
    if (part_sum0(integer_list, target_sum, i + 1, sum_)):
        return True
    if (part_sum0(integer_list, target_sum, i + 1, sum_ + integer_list[i])):
        return True
    return False


fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
y_lst = dir_lst[1]

can_x = False
can_y = False

dx = sum(x_lst) - abs(x)
if (dx % 2 == 1) or (dx < 0):
    pass
elif dx == 0:
    can_x = True
else:
    if part_sum0(x_lst, dx // 2):
        can_x = True

if can_x:
    dy = sum(y_lst) - abs(y)
    if (dy % 2 == 1) or (dy < 0):
        pass
    elif dy == 0:
        can_y = True
    else:
        if part_sum0(y_lst, dy // 2):
            can_y = True

if can_y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


def part_sum0(a, A):
    # 初期化
    N = len(a)
    dp = [[0 for i in range(A + 1)] for j in range(N + 1)]
    dp[0][0] = 1

    # DP
    for i in range(N):
        for j in range(A + 1):
            if a[i] <= j:
                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]
            else:
                dp[i + 1][j] = dp[i][j]
    return dp[N][A]


fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
y_lst = dir_lst[1]

can_x = False
can_y = False

dx = abs(sum(x_lst)) - abs(x)
if (dx % 2 == 1) or (dx < 0):
    pass
elif dx == 0:
    can_x = True
else:
    if part_sum0(x_lst, dx // 2):
        can_x = True

if can_x:
    dy = abs(sum(y_lst)) - abs(y)
    if (dy % 2 == 1) or (dy < 0):
        pass
    elif dy == 0:
        can_y = True
    else:
        if part_sum0(y_lst, dy // 2):
            can_y = True

if can_y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


def part_sum0(a, A):
    # 初期化
    N = len(a)
    dp = [[0 for i in range(A + 1)] for j in range(N + 1)]
    dp[0][0] = 1

    # DP
    for i in range(N):
        for j in range(A + 1):
            if a[i] <= j:  # i+1番目の数字a[i]を足せるかも
                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]
            else:  # 入る可能性はない
                dp[i + 1][j] = dp[i][j]
    return dp[N][A]


fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
y_lst = dir_lst[1]

can_x = False
dx = abs(sum(x_lst)) - abs(x)
if (dx % 2 == 1) or (dx < 0):
    pass
elif dx == 0:
    can_x = True
else:
    if part_sum0(x_lst, dx // 2):
        can_x = True

can_y = False
dy = abs(sum(y_lst)) - abs(y)
if (dy % 2 == 1) or (dy < 0):
    pass
elif dy == 0:
    can_y = True
else:
    if part_sum0(y_lst, dy // 2):
        can_y = True

if can_x and can_y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


def part_sum0(a, A):
    # 初期化
    N = len(a)
    dp = [[0 for i in range(A + 1)] for j in range(N + 1)]
    dp[0][0] = 1

    # DP
    for i in range(N):
        for j in range(A + 1):
            if a[i] <= j:  # i+1番目の数字a[i]を足せるかも
                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]
            else:  # 入る可能性はない
                dp[i + 1][j] = dp[i][j]
    return dp[N][A]


fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
y_lst = dir_lst[1]

can_x = False
dx = sum(x_lst) - x
if (dx % 2 == 1) or (dx < 0):
    pass
elif dx == 0:
    can_x = True
else:
    if part_sum0(x_lst, dx // 2):
        can_x = True

can_y = False
dy = sum(y_lst) - y
if (dy % 2 == 1) or (dy < 0):
    pass
elif dy == 0:
    can_y = True
else:
    if part_sum0(y_lst, dy // 2):
        can_y = True

if can_x and can_y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

cmd = list(input())
end = tuple(map(int, input().split()))

count = 0
while len(cmd) > 0:
    if cmd[0] == "F":
        count += 1
        cmd.pop(0)
    else:
        break

start = (0 + count, 0)

listX = []
listY = []
flag = False

if len(cmd) > 0:
    cmd.pop(0)
count = 0
for c in cmd:
    if c == "F":
        count += 1
    else:
        if flag:
            listX.append(count)
        else:
            listY.append(count)
        flag = not flag
        count = 0
if count > 0:
    if flag:
        listX.append(count)
    else:
        listY.append(count)

sumX = sum(listX)
sumY = sum(listY)

dx = abs(sumX - abs(end[0] - start[0]))
dy = abs(sumY - abs(end[1] - start[1]))


def t(num, list):
    if num == 0:
        return  True
    count = len(list)
    dp = np.zeros((count + 1, num + 1), dtype=bool)
    dp[0][0] = True

    for i in range(1, count + 1):
        for n in range(1, num + 1):
            if n == list[i - 1]:
                dp[i][n] = True
            elif list[i - 1] < n:
                dp[i][n] = dp[i - 1][n - list[i - 1]]
            else:
                dp[i][n] = dp[i - 1][n]

    return dp[count][num]

result = t(dx, listX)
if result:
    result = t(dy, listY)

print("Yes" if result else "No")

Submission status: Wrong Answer

Solution code:
s=list(map(len,input().split("T")))
x,y=map(int,input().split())
def f(t,w):
    m={(0,0):True}
    for i in range(len(t)):
        m[(i+1,w+t[i])]=True
        m[(i+1,w-t[i])]=True
    return (len(t),w) in m
print(["No","Yes"][f(s[2::2],x-s[0]) and f(s[1::2],y)])

Submission status: Wrong Answer

Solution code:
s=list(map(len,input().split("T")))
x,y=map(int,input().split())
def f(t,w):
    for i in range(1<<len(t)):
        z=0
        for j in range(len(t)):
            z+=[1,-1][i>>j&1]*t[j]
        if z==w:
            return True
    return False
print("Yes"if f(s[::2],x) and f(s[1::2],y) else "No")

Submission status: Wrong Answer

Solution code:
s = input()
x, y = map(int, input().split())
f = s.split('T')

def split_TF(s):
    s.split()
    I = []
    I2 = []
    x = True
    for tf in s:
        if tf == 'T':
            if x:
                I.append('-')
            else:
                I2.append('-')
            x = not x
            continue
        if x:
            I.append(tf)
        else:
            I2.append(tf)
    I = ''.join(I).split('-')
    I2 = ''.join(I2).split('-')
    I = [i for i in I if not i == '']
    I2 = [i for i in I2 if not i == '']
    return I, I2

def geti(n):
    if n >= 0: return n
    return abs(n) + 8000

I, I2 = split_TF(s)

X = 20000

def solve(I,t,f=True):
    dp = [[False for j in range(X)] for i in range(len(I))]
    if len(I) != 0:
        dp[0][len(I[0])] = True
        if not f:
            dp[0][geti(-1*len(I[0]))] = True

    for i in range(len(I)):
        if i == 0: continue
        di = len(I[i])
        for x2 in range(1, 8001):
            dp[i][x2] = dp[i-1][geti(x2-di)] or dp[i-1][geti(x2+di)]
            x2 = -1 * x2
            dp[i][geti(x2)] = dp[i-1][geti(x2-di)] or dp[i-1][geti(x2+di)]

    return len(dp) != 0 and dp[-1][geti(t)] or t == 0

reachable_x = solve(I,x)
if not reachable_x:
    print('No')
    exit()

reachable_y = solve(I2, y, False)

if reachable_x and reachable_y: print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
s = raw_input()
x, y = map(int, raw_input().split())

offset = 0
continuousMovement = 0
verticalMovement = []
horizontalMovement = []
flag = "start"

for letter in s:
    if letter == "F":
        continuousMovement += 1
    else:
        if flag == "vert":
            flag = "hori"
            verticalMovement.append(continuousMovement)
        elif flag == "hori":
            flag = "vert"
            horizontalMovement.append(continuousMovement)
        else:
            offset = continuousMovement
            flag = "vert"
        continuousMovement = 0
else:
    if flag == "vert":
        verticalMovement.append(continuousMovement)
    elif flag == "hori":
        horizontalMovement.append(continuousMovement)

distanceX = x - offset
distanceY = y

vertMovementVariation = {0, }
for x in verticalMovement:
    newVariation = set()
    for y in vertMovementVariation:
        newVariation.add(y + x)
        newVariation.add(y - x)
    vertMovementVariation = newVariation

horiMovementVariation = {0, }
for x in horizontalMovement:
    newVariation = set()
    for y in horiMovementVariation:
        newVariation.add(y + x)
        newVariation.add(y - x)
    horiMovementVariation = newVariation

if distanceX in horiMovementVariation and distanceY in vertMovementVariation:
    print "Yes"
else:
    print "No"

Submission status: Wrong Answer

Solution code:
def main():
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path) < 0:
        print("No")
        exit()
    count = 0
    findPath(count,position,[1,0])
    print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        else:
            return
    try:
        if S[index] == 'F':
            position = [position[0]+dic_vector[0],position[1]+dic_vector[1]]
            index+=1
            findPath(index,position,dic_vector)
        else:
            index+=1
            if dic_vector[0] !=0:
                findPath(index,position,[0,1])
                findPath(index,position,[0,-1])
            else:
                findPath(index,position,[1,0])
                findPath(index,position,[-1,0])
    except Exception:
        print("No")
        exit()

if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main()

Submission status: Wrong Answer

Solution code:
def main():
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path) < 0:
        print("No")
        exit()
    count = 0
    findPath(count,position,[1,0])
    print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        else:
            return
    try:
        if S[index] == 'F':
            index+=1
            findPath(index,[position[0]+dic_vector[0],position[1]+dic_vector[1]],dic_vector)
        else:
            index+=1
            if dic_vector[0]:
                findPath(index,position,[0,1])
                findPath(index,position,[0,-1])
            else:
                findPath(index,position,[1,0])
                findPath(index,position,[-1,0])
    except Exception:
        print("No")
        exit()

if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main()

Submission status: Wrong Answer

Solution code:
def main():
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path) < 0:
        print("No")
        exit()
    count = 0
    findPath(count,position,[1,0])
    print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        else:
            return
    try:
        if S[index] == 'F':
            position = [position[0]+dic_vector[0],position[1]+dic_vector[1]]
            index+=1
            findPath(index,position,dic_vector)
        else:
            index+=1
            if dic_vector[0]:
                findPath(index,position,[0,1])
                findPath(index,position,[0,-1])
            else:
                findPath(index,position,[1,0])
                findPath(index,position,[-1,0])
    except Exception:
        print("No")
        exit()

if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main()

Submission status: Wrong Answer

Solution code:
def main(S,target):
    dic_vector = [1,0]
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path)<0:
        print("No")
        exit()
    count = 0
    try:
        findPath(count,position,dic_vector)
    except Exception:
        print(Exception)
    print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        else:
            return
    if S[index] == 'F':
        position = [position[0]+dic_vector[0],position[1]+dic_vector[1]]
        findPath(index+1,position,dic_vector)
    else:
        if dic_vector[0]:
            dic_vector = [0,1]
            findPath(index+1,position,dic_vector)
            dic_vector = [0,-1]
            findPath(index+1,position,dic_vector)
        else:
            dic_vector = [1,0]
            findPath(index+1,position,dic_vector)
            dic_vector = [-1,0]
            findPath(index+1,position,dic_vector)


if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main(S,target)

Submission status: Wrong Answer

Solution code:
def main(S,target):
    dic_vector = [1,0]
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path)<0:
        print("No")
        exit()
    count = 0
    try:
        findPath(count,position,dic_vector)
    except Exception:
        print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        return
    if S[index] == 'F':
        position = [position[0]+dic_vector[0],position[1]+dic_vector[1]]
        findPath(index+1,position,dic_vector)
    else:
        if dic_vector[0]:
            dic_vector = [0,1]
            findPath(index+1,position,dic_vector)
            dic_vector = [0,-1]
            findPath(index+1,position,dic_vector)
        else:
            dic_vector = [1,0]
            findPath(index+1,position,dic_vector)
            dic_vector = [-1,0]
            findPath(index+1,position,dic_vector)


if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main(S,target)

Submission status: Wrong Answer

Solution code:
s = raw_input()
x, y = map(int, raw_input().split())

offset = 0
continuousMovement = 0
verticalMovement = []
horizontalMovement = []
flag = "start"

for letter in s:
    if letter == "F":
        continuousMovement += 1
    else:
        if flag == "vert":
            flag = "hori"
            verticalMovement.append(continuousMovement)
        elif flag == "hori":
            flag = "vert"
            horizontalMovement.append(continuousMovement)
        else:
            offset = continuousMovement
            flag = "vert"
        continuousMovement = 0
else:
    if flag == "vert":
        verticalMovement.append(continuousMovement)
    elif flag == "hori":
        horizontalMovement.append(continuousMovement)

distanceX = x - offset
distanceY = y

vertMovementVariation = [0, ]
for x in verticalMovement:
    newVariation = []
    for y in vertMovementVariation:
        newVariation.append(y + x)
        newVariation.append(y - x)
    vertMovementVariation = newVariation

horiMovementVariation = [0, ]
for x in horizontalMovement:
    newVariation = []
    for y in horiMovementVariation:
        newVariation.append(y + x)
        newVariation.append(y - x)
    horiMovementVariation = newVariation

if distanceX in horiMovementVariation and distanceY in vertMovementVariation:
    print "Yes"
else:
    print "No"

Submission status: Wrong Answer

Solution code:
s=input()
x,y=[int(i) for i in input().split()]
count=0
x_v=[]
y_v=[]
 
dir=1
for i in range(len(s)):
    if s[i]=="F":
        count=count+1
    else:
        if dir==1:
            if count!=0:
                x_v.append(count)
            dir=0
            count=0
 
        else:
            if count!=0:
                y_v.append(count)
            dir=1
            count=0
 
    if i==len(s)-1:
        if dir==1 and count!=0:
            x_v.append(count)
        elif dir==0 and count!=0:
            y_v.append(count)
 
number_x=sum(x_v)+abs(x)
x_check=0
dp_x=[[0 for i in range(number_x+1)] for j in range(len(x_v))]
if sum(x_v)!=0:
    dp_x[0][0]=1
 
for i in range(len(x_v)-1):
    for j in range(number_x+1):
        if dp_x[i][j]==1:
            dp_x[i+1][j+x_v[i+1]], dp_x[i+1][abs(j-x_v[i+1])]=1,1
 
if sum(x_v)!=0 and sum(x_v)>=abs(x) and x>=0:
  if dp_x[len(x_v)-1][abs(x-x_v[0])]==1:
    x_check=1
    
elif sum(x_v)!=0 and sum(x_v)>=abs(x) and x<0:
  if dp_x[len(x_v)-1][abs(x)+x_v[0]]==1:
    x_check=1
 
elif sum(x_v)==0:
  if x==0:
    x_check=1  
 
 
number_y=sum(y_v)
y_check=0
dp_y=[[0 for i in range(number_y+1)] for j in range(len(y_v))]
if sum(y_v)!=0:
    dp_y[0][y_v[0]]=1 
 
if sum(y_v)!=0 and x_check==1:
  for i in range(len(y_v)-1):
    for j in range(number_y+1):
          if dp_y[i][j]==1:
              dp_y[i+1][j+y_v[i+1]], dp_y[i+1][abs(j-y_v[i+1])]=1,1
 
if sum(y_v)!=0 and sum(y_v)>=abs(y):
  if dp_y[len(y_v)-1][abs(y)]==1:
    y_check=1
elif sum(y_v)==0:
  if y==0:
    y_check=1
 
if x_check==1 and y_check==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
x,y=[int(i) for i in input().split()]
count=0
x_v=[]
y_v=[]

dir=1
for i in range(len(s)):
    if s[i]=="F":
        count=count+1
    else:
        if dir==1:
            if count!=0:
                x_v.append(count)
            dir=0
            count=0

        else:
            if count!=0:
                y_v.append(count)
            dir=1
            count=0

    if i==len(s)-1:
        if dir==1 and count!=0:
            x_v.append(count)
        elif dir==0 and count!=0:
            y_v.append(count)

number_x=sum(x_v)
x_check=0
dp_x=[[0 for i in range(number_x+1)] for j in range(len(x_v))]
if sum(x_v)!=0:
    dp_x[0][0]=1

for i in range(len(x_v)-1):
    for j in range(number_x+1):
        if dp_x[i][j]==1:
            dp_x[i+1][j+x_v[i+1]], dp_x[i+1][abs(j-x_v[i+1])]=1,1
 

if sum(x_v)!=0 and sum(x_v)>=abs(x) and x>=0:
  if dp_x[len(x_v)-1][abs(x-x_v[0])]==1:
    x_check=1
    
elif sum(x_v)!=0 and sum(x_v)>=abs(x) and x<0:
  if dp_x[len(x_v)-1][abs(x+x_v[0])]==1:
    x_check=1
 
elif sum(x_v)==0:
  if x==0:
    x_check=1  


 
elif sum(x_v)==0:
  if x==0:
    x_check=1  
 
 
 
number_y=sum(y_v)
y_check=0
dp_y=[[0 for i in range(number_y+1)] for j in range(len(y_v))]
if sum(y_v)!=0:
    dp_y[0][y_v[0]]=1 
 
if sum(y_v)!=0 and x_check==1:
  for i in range(len(y_v)-1):
    for j in range(number_y+1):
          if dp_y[i][j]==1:
              dp_y[i+1][j+y_v[i+1]], dp_y[i+1][abs(j-y_v[i+1])]=1,1
 
if sum(y_v)!=0 and sum(y_v)>=abs(y):
  if dp_y[len(y_v)-1][abs(y)]==1:
    y_check=1
elif sum(y_v)==0:
  if y==0:
    y_check=1

if x_check==1 and y_check==1:
    print("Yes")
else:
    print("No")