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:
# coding: utf-8
from itertools import accumulate
s=input()
x,y=map(int,input().split())
tmp=s.split('T')
xm=[0]
ym=[0]
for i in range(len(tmp)):
    if i%2==0:
        xm.append(len(tmp[i]))
    else:
        ym.append(len(tmp[i]))
if s[0]=='F':
    x-=xm[0]
    xm[0]=0
xm=list(accumulate(xm))
ym=list(accumulate(ym))
Dx=(xm[-1]-x)/2.0
Dy=(ym[-1]-y)/2.0
if Dx!=int(Dx) or Dy!=int(Dy):
    print('No')
    exit()
f=[False,False]
for i in range(len(xm)):
    for j in range(i,len(xm)):
        if xm[j]-xm[i]==Dx:
            f[0]=True
            break
for i in range(len(ym)):
    for j in range(i,len(ym)):
        if ym[j]-ym[i]==Dy:
            f[1]=True
            break
print('Yes' if f[0] and f[1] else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def no():
    print("No")
    return

def main():
    s = input()
    x, y = list(map(int, input().split()))
    x_start = 0
    f_count = 0
    x_dirs = []
    y_dirs = []
    is_x = True # xを向いてるか
    t_exist = False
    for c in s:
        if c == "T":
            if f_count > 0:
                if is_x:
                    if t_exist:
                        x_dirs.append(f_count)
                else:
                    y_dirs.append(f_count)
            t_exist = True
            is_x = not is_x
            f_count = 0
            continue
        f_count += 1
        if not t_exist:
            x_start += 1
    if f_count > 0:
        if is_x:
            x_dirs.append(f_count)
        else:
            y_dirs.append(f_count)

    memo_x = [{} for _ in range(len(x_dirs)+1)]
    memo_y = [{} for _ in range(len(y_dirs)+1)]
    memo_x[0][x_start] = True
    memo_y[0][0] = True

    for i, dx in enumerate(x_dirs):
        for j in memo_x[i]:
            memo_x[i+1][j-dx] = True
            memo_x[i+1][j+dx] = True
    for i, dy in enumerate(y_dirs):
        for j in memo_y[i]:
            memo_y[i+1][j-dy] = True
            memo_y[i+1][j+dy] = True

    if x not in memo_x[len(x_dirs)]:
        return no()
    if y not in memo_y[len(y_dirs)]:
        return no()
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
data = raw_input().split("T")
x_a, y_a = map(int,raw_input().split(" "))
x = []
y = []

for a in range(len(data)):
   if a % 2 == 0:
      x.append( data[a].count("F") )
   else:
      y.append( data[a].count("F") )

x_now = x[0]
x = x[1:]

x = sorted(x)
y = sorted(y)

for xx in range(0,len(x)):
  if x_now > x_a:
    x_now -= x[xx]
  else:
    x_now += x[xx]
  
y_now = 0
for yy in range(0,len(y)):
  if y_now > y_a:
    y_now -= y[yy]
  else:
    y_now += y[yy]

if x_now == x_a and y_now == y_a:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

Solution code:
data = raw_input().split("T")
x_a, y_a = map(int,raw_input().split(" "))
x = []
y = []

for a in range(len(data)):
   if a % 2 == 0:
      x.append( data[a].count("F") )
   else:
      y.append( data[a].count("F") )

x_now = x[0]
x = x[1:]

x = sorted(x)
y = sorted(y)

for xx in range(1,len(x)):
  if x_now > x_a:
    x_now -= x[xx]
  else:
    x_now += x[xx]
  
y_now = 0
for yy in range(0,len(y)):
  if y_now > y_a:
    y_now -= y[yy]
  else:
    y_now += y[yy]

if x_now == x_a and y_now == y_a:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

Solution code:
import math

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

sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x = x-sn[0]
sx = []
sy = []
# 配列をx軸とy軸に分割
if len(sn) >= 3:
    sy = sn[1::2]
    sx = sn[2::2]
elif len(sn) == 2:
    sy.append(sn[1])
    sx.append(0)
else:
    sy.append(0)
    sx.append(0)

xsig = 0
ysig = 0

# x軸について
tarX = int(abs(x))

sx.sort()
sx.reverse()
for i in range(len(sx)):
    if tarX >= sx[i]:
        tarX -= sx[i]
    else:
        tarX += sx[i]

if tarX == 0:
    xsig = 1 

# y軸について
tarY = int(abs(y))
sy.sort()
sy.reverse()
for i in range(len(sy)):
    if tarY >= sy[i]:
        tarY -= sy[i]
    else:
        tarY += sy[i]

if tarY == 0:
    ysig = 1 


# print(tarX)
# print(tarY)

if xsig == 1 and ysig == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
data = raw_input().split("T")
x_a, y_a = map(int,raw_input().split(" "))
x = []
y = []

for a in range(len(data)):
   if a % 2 == 0:
      x.append( data[a].count("F") )
   else:
      y.append( data[a].count("F") )

x = sorted(x)
y = sorted(y)

x_now = x[0]
for xx in range(1,len(x)):
  if x_now > x_a:
    x_now -= x[xx]
  else:
    x_now += x[xx]
  
y_now = 0
for yy in range(0,len(y)):
  if y_now > y_a:
    y_now -= y[yy]
  else:
    y_now += y[yy]

if x_now == x_a and y_now == y_a:
  print "Yes"
else:
  print "No"

Submission status: Wrong Answer

Solution code:
import math

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

sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x = x-sn[0]
sx = []
sy = []
# 配列をx軸とy軸に分割
if len(sn) >= 3:
    sy = sn[1::2]
    sx = sn[2::2]
elif len(sn) == 2:
    sy.append(sn[1])
    sx.append(0)
else:
    sy.append(0)
    sx.append(0)

xsig = 0
ysig = 0

# x軸について
tarX = int(abs(sum(sx) - abs(x)))

sx.sort()
sx.reverse()
for i in range(len(sx)):
    if tarX >= sx[i]:
        tarX -= sx[i]

if tarX == 0:
    xsig = 1 

# y軸について
tarY = int(abs(sum(sy) - abs(y)))
sy.sort()
sy.reverse()
for i in range(len(sy)):
    if tarY >= sy[i]:
        tarY -= sy[i]

if tarY == 0:
    ysig = 1 


# print(tarX)
# print(tarY)

if xsig == 1 and ysig == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

nx = 0
ny = 0
np = "+x"
for i in s:
    if i == "F" and np == "+x":
        nx += 1

    elif i == "F" and np == "-x":
        nx -= 1

    elif i == "F" and np == "+y":
        ny += 1

    elif i == "F" and np == "-y":
        ny -= 1

    elif i == "T" and np == "+x":
        if(y-ny) > 0:
            np = "+y"
        elif(y-ny) <= 0:
            np = "-y"

    elif i == "T" and np == "-x":
        if(y - ny) > 0:
            np = "+y"
        elif(y-ny) <= 0:
            np = "-y"
    
    elif i == "T" and np == "+y":
        if(x - nx) > 0:
            np = "+x"
        elif(x-nx) <= 0:
            np = "-x"
    elif i == "T" and np == "-y":
        if(x - nx) > 0:
            np = "+x"
        elif(x-nx) <= 0:
            np = "-x"

if x == nx and y == ny:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input().strip()
x,y=[int(i) for i in input().split()]

# print(s,x,y)
F_list=s.split("T")
# print(F_list)
x_F_num=[]
y_F_num=[]
for i in range(len(F_list)):
    if i%2==0:
        x_F_num.append(len(F_list[i]))
    else:
        y_F_num.append(len(F_list[i]))
# print(x_F_num,y_F_num)

# #x
# ikeru=[]
# next_ikeru=[]
# ikeru.append(x_F_num[0])
# for i in range(1,len(x_F_num)):
#     num=x_F_num[i]
#     for j in ikeru:
#         next_ikeru.append(j+num)
#         next_ikeru.append(j-num)
#     ikeru=list(set(next_ikeru))
# x_ok=x in ikeru
# #y
# ikeru=[]
# next_ikeru=[]
# ikeru.append(y_F_num[0])
# ikeru.append(0-y_F_num[0])
# for i in range(1,len(y_F_num)):
#     num=y_F_num[i]
#     for j in ikeru:
#         next_ikeru.append(j+num)
#         next_ikeru.append(j-num)
#     ikeru=list(set(next_ikeru))
# y_ok=y in ikeru
#
# if x_ok==True and y_ok==True:
#     print('Yes')
# else:
#     print('No')

MAX_INDEX=8000
dp=[[False for j in range(MAX_INDEX*2+1)] for i in range(len(x_F_num))]
x_ok=False
if len(x_F_num)!=0:
    dp[0][x_F_num[0]+MAX_INDEX]=True
    for i in range(1,len(x_F_num)):
        num=x_F_num[i]
        for j in range(MAX_INDEX*2+1):
            if dp[i-1][j]==True:
                dp[i][j+num]=True
                dp[i][j-num]=True
    x_ok=dp[len(x_F_num)-1][x+MAX_INDEX]
else:
    if x==0:
        x_ok=True

dp=[[False for j in range(MAX_INDEX*2+1)] for i in range(len(y_F_num))]
y_ok=False
if len(y_F_num)!=0:
    dp[0][y_F_num[0]+MAX_INDEX]=True
    dp[0][MAX_INDEX-y_F_num[0]]=True
    for i in range(1,len(y_F_num)):
        num=y_F_num[i]
        for j in range(MAX_INDEX*2+1):
            if dp[i-1][j]==True:
                dp[i][j+num]=True
                dp[i][j-num]=True
    y_ok=dp[len(y_F_num)-1][y+MAX_INDEX]
else:
    if y==0:
        y_ok==True

if x_ok==True and y_ok==True:
    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:
            x_v.append(count)
            dir=0
            count=0
        else:
            y_v.append(count)
            dir=1
            count=0
    if i==len(s)-1:
        if dir==1:
            x_v.append(count)
            dir=0
            count=0
        else:
            y_v.append(count)
            dir=1
            count=0        

x_now=sum(x_v)-x
y_now=sum(y_v)-y
x_check=0
y_check=0


if x_now%2==1:
    x_check=0  
else:
    x_check=1    
if y_now%2==1:
    y_check=0    
else:
    y_check=1    


"""
for i in range(len(y_v)):
    if count(y_now%2)==1:
        break

    if y_now==y:
        y_check=1
        break
    y_now=y_now-2*y_v[i]
"""


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

Submission status: Wrong Answer

Solution code:
val = input()
num = [int(x) for x in input().split()]

F_list = val.split("T")
x_list = []
y_list = []
for x in range(0, len(F_list)):
    if x % 2 == 0:
        x_list.append(F_list[x].count("F"))
    else:
        y_list.append(F_list[x].count("F"))

res = False

if len(y_list) == 0:
    if num[0] == x_list[0] and num[1] == 0:
        print("Yes")
    else:
        print("No")

else:
    x = []
    y = []

    x.append(x_list[0])
    x.append(-1*x_list[0])
    y.append(y_list[0])
    y.append(-1*y_list[0])

    for i in x_list[1:]:
        tmp = [a+i for a in x]
        tmp2 = [a-i for a in x]
        x = tmp + tmp2
        x = list(set(x))[:len(x)]

    for j in y_list[1:]:
        tmp = [b+i for b in y]
        tmp2 = [b-i for b in y]
        y = tmp + tmp2
        y = list(set(y))[:len(y)]
    if x.count(abs(num[0])) != 0 and y.count(abs(num[1])) != 0:
        res = True

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

Submission status: Wrong Answer

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

state = [0, 0]
direction = [1, 0]
if s.count('F') < abs(x) + abs(y):
    print ('No')
else:
    for i in s:
        if i == 'F':
            state[0] = state[0] + direction[0]
            state[1] = state[1] + direction[1]
        else:
            if direction[1] == 0:
                if state[1] <= y:
                    direction = [0, 1]
                else:
                    direction = [0, -1]
            else:
                if state[0] <= x:
                    direction = [1, 0]
                else:
                    direction = [-1, 0]
    if state == [x, y]:
        print ('Yes')
    else:
        print ('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
a=input().strip()
x,y=[int(i) for i in input().split(" ")]

e1=[0]
e2=[0]
f=0
t=0
for i in a:
  if i=='F':
    f+=1
  elif i=='T':
    if f!=0:
      if t==0:
        e1.append(f)
      elif t==1:
        e2.append(f)
    t=(t+1)%2
    f=0

if t==0:
  e1.append(f)
elif t==1:
  e2.append(f)

s={0}
o=0
for i in e1:
  if a[0]==0 and o==1:
    s=set([k+i for k in s])
  else:
    sp=set([k+i for k in s])
    sm=set([k-i for k in s])
    s=sp|sm

r={0}
for i in e2:
  rp=set([k+i for k in r])
  rm=set([k-i for k in r])
  r=rp|rm


if x in s and y in r:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

f_num = 0
t_num = 0
for o in s:
    if o == "F":
        f_num += 1
    else:
        t_num += 1
if f_num == 0:
    if x == 0 and y == 0:
        print("Yes")
    else:
        print("No")
else:
    f = s.split("T")
    rx = len(f[0])
    ry = 0
    for i in range(1, t_num+1):
        if i % 2 == 0:
            if x - rx > 0:
                rx += len(f[i])
            else:
                rx -= len(f[i])
        else:
            if y - ry > 0:
                ry += len(f[i])
            else:
                ry -= len(f[i])

    if x == rx and y == ry:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import math

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

sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x = x-sn[0]
sx = []
sy = []
# 配列をx軸とy軸に分割
if len(sn) >= 3:
    sy = sn[1::2]
    sx = sn[2::2]
elif len(sn) == 2:
    sy.append(sn[1])
    sx.append(0)
else:
    sy.append(0)
    sx.append(0)

xsig = 0
ysig = 0

# x軸について
tarX = int(abs(sum(sx) - abs(x)))

sx.reverse()
for i in range(len(sx)):
    if tarX >= sx[i]:
        tarX -= sx[i]

if tarX == 0:
    xsig = 1 

tarX = int(abs(sum(sx) - abs(x)))

sx.sort()
for i in range(len(sx)):
    if tarX >= sx[i]:
        tarX -= sx[i]

if tarX == 0:
    xsig = 1 

# y軸について
tarY = int(abs(sum(sy) - abs(y)))
sy.reverse()
for i in range(len(sy)):
    if tarY >= sy[i]:
        tarY -= sy[i]

if tarY == 0:
    ysig = 1 

tarY = int(abs(sum(sy) - abs(y)))
sy.sort()
for i in range(len(sy)):
    if tarY >= sy[i]:
        tarY -= sy[i]

if tarY == 0:
    ysig = 1 


# print(tarX)
# print(tarY)

if xsig == 1 and ysig == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = input()
x, y = list(map(int, input().split()))
# S = "FTFFFTTFFTFFTFFTFFF"
# x, y = 4, -1
lst = list(map(len, S.split("T")))
print(lst)
e = lst[0::2] # e = [1, 3]
o = lst[1::2]
xl = [0]
yl = [0]
for num in e:
    xl = [xl[i]+num for i in range(len(xl))] + [xl[i]-num for i in range(len(xl))]
if (x not in xl):
    print("No")
    for num in o:
        yl = [yl[i]+num for i in range(len(yl))] + [yl[i]-num for i in range(len(yl))]
    if (y not in yl):
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
s=input().strip()
x,y=[int(i) for i in input().split()]

# print(s,x,y)
F_list=s.split("T")
# print(F_list)
x_F_num=[]
y_F_num=[]
for i in range(len(F_list)):
    if i%2==0:
        x_F_num.append(len(F_list[i]))
    else:
        y_F_num.append(len(F_list[i]))
# print(x_F_num,y_F_num)

# #x
# ikeru=[]
# next_ikeru=[]
# ikeru.append(x_F_num[0])
# for i in range(1,len(x_F_num)):
#     num=x_F_num[i]
#     for j in ikeru:
#         next_ikeru.append(j+num)
#         next_ikeru.append(j-num)
#     ikeru=list(set(next_ikeru))
# x_ok=x in ikeru
# #y
# ikeru=[]
# next_ikeru=[]
# ikeru.append(y_F_num[0])
# ikeru.append(0-y_F_num[0])
# for i in range(1,len(y_F_num)):
#     num=y_F_num[i]
#     for j in ikeru:
#         next_ikeru.append(j+num)
#         next_ikeru.append(j-num)
#     ikeru=list(set(next_ikeru))
# y_ok=y in ikeru
#
# if x_ok==True and y_ok==True:
#     print('Yes')
# else:
#     print('No')

MAX_INDEX=8000
dp=[[False for j in range(MAX_INDEX*2+1)] for i in range(len(x_F_num))]
if len(x_F_num)!=0:
    dp[0][x_F_num[0]+MAX_INDEX]=True
    for i in range(1,len(x_F_num)):
        num=x_F_num[i]
        for j in range(MAX_INDEX*2+1):
            if dp[i-1][j]==True:
                dp[i][j+num]=True
                dp[i][j-num]=True
    x_ok=dp[len(x_F_num)-1][x+MAX_INDEX]
else:
    x_ok=False

dp=[[False for j in range(MAX_INDEX*2+1)] for i in range(len(y_F_num))]
if len(y_F_num)!=0:
    dp[0][y_F_num[0]+MAX_INDEX]=True
    dp[0][MAX_INDEX-y_F_num[0]]=True
    for i in range(1,len(y_F_num)):
        num=y_F_num[i]
        for j in range(MAX_INDEX*2+1):
            if dp[i-1][j]==True:
                dp[i][j+num]=True
                dp[i][j-num]=True
    y_ok=dp[len(y_F_num)-1][y+MAX_INDEX]
else:
    y_ok=False

if x_ok==True and y_ok==True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

nx = 0
ny = 0
np = "+x"
for i in s:
    if i == "F" and np == "+x":
        nx += 1

    elif i == "F" and np == "-x":
        nx -= 1

    elif i == "F" and np == "+y":
        ny += 1

    elif i == "F" and np == "-y":
        ny -= 1

    elif i == "T" and np == "+x":
        if(y-ny) >= 0:
            np = "+y"
        elif(y-ny) < 0:
            np = "-y"

    elif i == "T" and np == "-x":
        if(y - ny) >= 0:
            np = "+y"
        elif(y-ny) < 0:
            np = "-y"
    
    elif i == "T" and np == "+y":
        if(x - nx) >= 0:
            np = "+x"
        elif(x-nx) < 0:
            np = "-x"
    elif i == "T" and np == "-y":
        if(x - nx) >= 0:
            np = "+x"
        elif(x-nx) < 0:
            np = "-x"

if x == nx and y == ny:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s=input()
st=input().split()
x=int(st[0]);y=int(st[1])
F=0
T=0
Tindex=[]
N=len(s)
for i in range(N):
    if s[i]=="F":
        F+=1
    else:
        T+=1
        Tindex.append(i)
M=len(Tindex)
if M!=0:
    for i in range(1,len(Tindex)):
        if Tindex[i-1]+1==Tindex[i]:
            M-=1
if M==0:
    if x==F and y==0:
        print("Yes")
    else:
        print("No")
elif M==1:
    if len(Tindex)%2==1:
        if x==Tindex[0] and abs(y)==F-1-Tindex[len(Tindex)-1]:
            print("Yes")
        else:
            print("No")
    else:
        if y==0 and (abs(x)==F or abs(x)==abs(Tindex[0]-N+1+Tindex[len(Tindex)-1])):
            print("Yes")
        else:
            print("No")
else:
    if (abs(x)+abs(y))<=F and (F-x-y)%2==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
s = input()
a, b = 0, 0
x, y = map(int, input().split())
dx = 1
dy = 0
for tf in s:
    if tf == 'T':
        if dy == 0:
            l = y - b
            if l > 0: dy = 1
            else: dy = -1
            dx = 0
        elif dx == 0:
            k = x - a
            if k > 0: dx = 1
            else: dx = -1
            dy = 0
    else:
        a += dx*1
        b += dy*1
if a == x and y == b: print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
s = input()
a, b = 0, 0
x, y = map(int, input().split())
dx = 1
dy = 0
ye = 1
xe = 1
for tf in s:
    if tf == 'T':
        if dy == 0:
            l = y - b
            if l > 0:
                dy = 1
            elif l < 0:
                dy = -1
            else:
                dy = ye
                ye = -1 * ye
            dx = 0
        elif dx == 0:
            k = x - a
            if k > 0:
                dx = 1
            elif k < 0: 
                dx = -1
            else:
                dx = -1 * xe
                xe = -1 * xe
            dy = 0
    else:
        a += dx*1
        b += dy*1
if a == x and y == b: print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
S = input()
x, y = list(map(int, input().split()))
# S = "FTFFTFFF"
# x, y = 4, 2
lst = list(map(len, S.split("T")))
e = lst[0::2] # e = [1, 3]
o = lst[1::2]
xl = [0]
yl = [0]
for num in e:
    xl = [xl[i]+num for i in range(len(xl))] + [xl[i]-num for i in range(len(xl))]
if (x not in xl):
    print("No")
    exit()
for num in o:
    yl = [yl[i]+num for i in range(len(yl))] + [yl[i]-num for i in range(len(yl))]
if (y not in yl):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import math

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

sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x = x-sn[0]
sx = []
sy = []
# 配列をx軸とy軸に分割
if len(sn) >= 3:
    sy = sn[1::2]
    sx = sn[2::2]
elif len(sn) == 2:
    sy.append(sn[1])
    sx.append(0)
else:
    sy.append(0)
    sx.append(0)

xsig = 0
ysig = 0

# x軸について
tarX = int(abs(sum(sx) - abs(x)))

sx.reverse()
for i in range(len(sx)):
    if tarX >= sx[i]:
        tarX -= sx[i]

if tarX == 0:
    xsig = 1 

# y軸について
tarY = int(abs(sum(sy) - abs(y)))
sy.reverse()
for i in range(len(sy)):
    if tarY >= sy[i]:
        tarY -= sy[i]

if tarY == 0:
    ysig = 1 

# print(tarX)
# print(tarY)

if xsig == 1 and ysig == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

state = [0, 0]
direction = [1, 0]
for i in s:
    if i == 'F':
        state[0] = state[0] + direction[0]
        state[1] = state[1] + direction[1]
    else:
        if direction[1] == 0:
            if state[1] <= y:
                direction = [0, 1]
            else:
                direction = [0, -1]
        else:
            if state[0] <= x:
                direction = [1, 0]
            else:
                direction = [-1, 0]
if state == [x, y]:
    print ('Yes')
else:
    print ('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def no():
    print("No")
    return

def main():
    s = input()
    x, y = list(map(int, input().split()))
    x_count = 0
    y_count = 0
    t_count = 0
    is_x = True # xを向いてるか
    f_before_t = 0
    t_exist = False
    for c in s:
        if c == "T":
            t_count += 1
            t_exist = True
            continue
        if not t_exist:
            f_before_t += 1
        if t_count % 2 == 0:
            # 向いている方向に進む
            if is_x:
                x_count += 1
            else:
                y_count += 1
        else:
            if is_x:
                y_count += 1
            else:
                x_count += 1
            is_x = not is_x
        t_count = 0
    if (x % 2) != (x_count % 2):
        return no()
    if abs(x) > x_count:
        return no()
    if (y % 2) != (y_count % 2):
        return no()
    if abs(y) > y_count:
        return no()
    if (x_count - f_before_t*2) < x*-1:
        return no()
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
a, b = 0, 0
x, y = map(int, input().split())
dx = 1
dy = 0
for tf in s:
    if tf == 'T':
        if dx == 1 and dy == 0:
            l = y - b
            if l >= 0:
                dy = 1
            else:
                dy = -1
            dx = 0
        elif dx == 0 and dy == 1:
            k = x - a
            if k >= 0:
                dx = 1
            else:
                dx = -1
            dy = 0
        elif dx == -1 and dy == 0:
            l = y - b
            if l >= 0:
                dy = 1
            else:
                dy = -1
            dx = 0
        elif dx == 0 and dy == -1:
            k = x - a
            if k >= 0:
                dx = 1
            else:
                dx = -1
            dy = 0
    else:
        a += dx*1
        b += dy*1
if a == x and y == b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
s=list(raw_input())
x,y=map(int,raw_input().split())
#print s
flag=0
sx=[]
sy=[]
for i in s:
	if i=="T":
		flag=(flag+1)%2
	elif flag==0:
		sx.append(i)
	else:
		sy.append(i)

len_sx=len(sx)
len_sy=len(sy)
a=[]
b=[]

for i in range(len_sx+1):
	a.append(i*-1+(len_sx-i)*1)
	
for i in range(len_sy+1):
	b.append(i*-1+(len_sy-i)*1)

#print a
#print b

if x in a and y in b:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def no():
    print("No")
    return

def main():
    s = input()
    x, y = list(map(int, input().split()))
    x_count = 0
    y_count = 0
    t_count = 0
    is_x = True # xを向いてるか
    for c in s:
        if c == "T":
            t_count += 1
            continue
        if t_count % 2 == 0:
            # 向いている方向に進む
            if is_x:
                x_count += 1
            else:
                y_count += 1
        else:
            if is_x:
                y_count += 1
            else:
                x_count += 1
            is_x = not is_x
        t_count = 0
    if (x % 2) != (x_count % 2):
        return no()
    if abs(x) > x_count:
        return no()
    if (y % 2) != (y_count % 2):
        return no()
    if abs(y) > y_count:
        return no()
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import itertools

s = input()
x,y = [int(x) for x in input().split()]

xf = []
yf = []

now = xf
t = 0
for i in s:
    if i == 'F':
        t += 1
    else:
        now.append(t)
        t = 0
        if now == xf:
            now = yf
        else:
            now = xf
now.append(t)


xt = sum(xf)
xb = False
if xt == x:
    xb = True
elif x > 0:
    if xt < x:
        print('No')
        sys.exit()
    else:
        xt = x - xt
        for i in range(1,len(xf)):
            for j in itertools.permutations(xf[1:],i):
                if sum(j) == xt:
                    xb = True
                    break
            if xb:
                break
else:
    xt = xf[0] * 2 - sum(xf)
    if xt == x:
        xb = True
    else:
        print(xt)
        if xt < x:
            print('No')
            sys.exit()
        else:
            xt = abs(x - xt)
            for i in range(1,len(xf)):
                for j in itertools.permutations(xf[1:],i):
                    if sum(j) == xt:
                        xb = True
                        break
                if xb:
                    break
if not xb:
    print('No')
    sys.exit()


yt = sum(yf)
yb = False
if yt == y:
    yb = True
elif y > 0:
    if yt < y:
        print('No')
        sys.exit()
    else:
        yt = y - yt
        for i in range(1,len(yf)):
            for j in itertools.permutations(yf[1:],i):
                if sum(j) == yt:
                    yb = True
                    break
            if yb:
                break
else:
    yt = -yt
    if yt == y:
        yb = True
    else:
        if yt < y:
            print('No')
            sys.exit()
        else:
            yt = abs(y - yt)
            for i in range(1,len(yf)):
                for j in itertools.permutations(yf,i):
                    if sum(j) == yt:
                        yb = True
                        break
                if yb:
                    break
if not yb:
    print('No')
    sys.exit()

if xb and yb:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

M = 8000
N = 2*M+1

def shift(p):
    return p+M+1

def no():
    print("No")
    return

def main():
    s = input()
    x, y = list(map(int, input().split()))
    x_count = 0
    y_count = 0
    t_count = 0
    is_x = True # xを向いてるか
    for c in s:
        if c == "T":
            t_count += 1
            continue
        if t_count % 2 == 0:
            # 向いている方向に進む
            if is_x:
                x_count += 1
            else:
                y_count += 1
        else:
            if is_x:
                y_count += 1
            else:
                x_count += 1
            is_x = not is_x
        t_count = 0
    if (x % 2) != (x_count % 2):
        return no()
    if x > x_count:
        return no()
    if (y % 2) != (y_count % 2):
        return no()
    if y > y_count:
        return no()
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools

def possibility_check(target_value, target_list):
    if len(target_list) == 1:
        if (target_list[0] == target_value) or (target_list[0] * (-1) == target_value):
            return True
        else:
            return False
    #print('target: ', target_value, target_list)
    for i in range(len(target_list)):
        for comb in itertools.combinations(range(len(target_list)), i + 1):
            check_cnt = 0
            for j, each in enumerate(target_list):
                if j in comb:
                    check_cnt -= each
                else:
                    check_cnt += each
            if check_cnt == target_value:
                return True
    return False

mvx = []
mvy = []
set_x  = True
cnt = 0
s_base = [i for i in input()]
tx, ty = [int(i) for i in input().split()]

for i, s in enumerate(s_base):
    if s == 'F':
        cnt += 1
        if i == len(s_base)-1:
            if set_x:
                mvx.append(cnt)
            else:
                mvy.append(cnt)
    else:
        if set_x:
            mvx.append(cnt)
            set_x = False
            cnt = 0
        else:
            mvy.append(cnt)
            set_x = True
            cnt = 0

fmove = mvx.pop(0)
tx -= fmove

#print(possibility_check(tx, mvx))
#print(possibility_check(ty, mvy))

if possibility_check(tx, mvx) and possibility_check(ty, mvy):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = list(input())
x,y = list(map(int,input().split()))
myx,myy = 0,0
vector = "right"
line_x,line_y = x,y

def turn(vector,myx,myy):
    if vector == "up" or vector == "down":
        if myx <= line_x:
            return "right"
        else:
            return "left"
    else:
        if myy <= line_y:
            return "up"
        else:
            return "down"

def go(vector):
    if vector == "up":
        return 0,1
    elif vector == "right":
        return 1,0
    elif vector == "down":
        return 0,-1
    else:
        return -1,0

for exe in s:
    if exe == "F":
        plus_x,plus_y = go(vector)
        myx += plus_x
        myy += plus_y
    else:
        vector = turn(vector,myx,myy)
    # print(myx,myy,vector)

if myx == x and myy == y:
    print("Yes")
else:
    print("No")