Submission #5086478


Source Code Expand

Copy
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
vector<int> d;
bool dpx[20005][4];//{right:0,up:1,left:2,down:3}
bool dpy[20005][4];//{right:0,up:1,left:2,down:3}
string s;
int x,y,j=0;
int tmp=0;

int main(void)
{
  memset(dpx,false,sizeof(dpx));
  memset(dpy,false,sizeof(dpy));
  cin >> s;
  cin >> x >> y;
  int ssize=int(s.size());
  for (int i = 0; i < ssize; ++i)
    {
      if(s[i]=='F')
	{
	  tmp++;
	}
      else if(s[i]=='T') {
	d.push_back(tmp);
	tmp=0;
      }
      if(i==ssize-1)
	{
	  d.push_back(tmp);
	}
    }
  /*for (int i = 0; i < int(d.size()); ++i)
    {
    cout << d[i] << endl;
    }*/
  int dsize=int(d.size());
  dpx[10000+d[0]][0]=true;
  dpy[10000][0]=true;
  for(int j=1;j<dsize;j++)
    {
      for (int i = 0; i <= 20000; ++i)
	{
	  if(j%2!=0)
	    {
	      if(dpx[i][0] || dpx[i][2])
		{
		  dpx[i][1]=true;
		  dpx[i][3]=true;
		  // cout << i << " A" << endl;
		}
	    }
	  else
	    {
	      if(dpx[i][1] || dpx[i][3])
		{
		  dpx[i+d[j]][0]=true;
		  dpx[i-d[j]][2]=true;
		  //cout << i+d[j] << " & " << i-d[j] <<  " B" << endl;
		}
	    }
	}
    }

  for(int j=1;j<dsize;j++)
    {
      for (int i = 0; i <= 20000; ++i)
	{
	  if(j%2!=0)
	    {
	      if(dpy[i][0] || dpy[i][2])
		{
		  dpy[i+d[j]][1]=true;
		  dpy[i-d[j]][3]=true;
		  //cout << i+d[j] << " & " << i-d[j] <<  " D" << endl;
		}
	    }
	  else
	    {
	      if(dpy[i][1] || dpy[i][3])
		{
		  dpy[i][0]=true;
		  dpy[i][2]=true;
		  //cout << i << " C" << endl;
		}
	    }
	}
    }
  for (int i = 0; i < 4; ++i)
    {
      if(dpx[10000+x][i] && dpy[10000+y][i])
	{
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  cout << "No" << endl;
  return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User Tendaysago
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1906 Byte
Status
Exec Time 413 ms
Memory 512 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 0 / 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 1 ms 384 KB
0_01.txt 1 ms 384 KB
0_02.txt 1 ms 384 KB
0_03.txt 1 ms 384 KB
0_04.txt 1 ms 384 KB
0_05.txt 2 ms 384 KB
1_00.txt 2 ms 384 KB
1_01.txt 2 ms 384 KB
1_02.txt 2 ms 384 KB
1_03.txt 2 ms 384 KB
1_04.txt 2 ms 384 KB
1_05.txt 2 ms 384 KB
1_06.txt 208 ms 384 KB
1_07.txt 208 ms 384 KB
1_08.txt 279 ms 512 KB
1_09.txt 279 ms 512 KB
1_10.txt 277 ms 512 KB
1_11.txt 277 ms 512 KB
1_12.txt 140 ms 384 KB
1_13.txt 140 ms 384 KB
1_14.txt 209 ms 512 KB
1_15.txt 209 ms 384 KB
1_16.txt 208 ms 384 KB
1_17.txt 208 ms 384 KB
1_18.txt 204 ms 384 KB
1_19.txt 204 ms 384 KB
1_20.txt 204 ms 384 KB
1_21.txt 208 ms 384 KB
1_22.txt 207 ms 384 KB
1_23.txt 205 ms 384 KB
1_24.txt 209 ms 384 KB
1_25.txt 204 ms 384 KB
1_26.txt 405 ms 512 KB
1_27.txt 413 ms 512 KB
1_28.txt 204 ms 384 KB
1_29.txt 207 ms 384 KB
1_30.txt 106 ms 384 KB
1_31.txt 100 ms 384 KB
1_32.txt 54 ms 384 KB
1_33.txt 52 ms 384 KB
1_34.txt 27 ms 384 KB
1_35.txt 25 ms 384 KB
1_36.txt 15 ms 384 KB
1_37.txt 17 ms 384 KB
1_38.txt 8 ms 384 KB
1_39.txt 8 ms 384 KB
1_40.txt 5 ms 384 KB
1_41.txt 5 ms 384 KB
1_42.txt 152 ms 384 KB
1_43.txt 160 ms 384 KB
1_44.txt 143 ms 384 KB
1_45.txt 146 ms 384 KB
1_46.txt 145 ms 384 KB
1_47.txt 152 ms 384 KB
1_48.txt 169 ms 384 KB
1_49.txt 145 ms 384 KB