Submission #2009622


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  int x,y;
  cin>>x>>y;
  int d=0;
  vector<vi> a(2);
  rep(i,n){
    int t=0;
    while(s[i]=='F'&&i<n)t++,i++;
    a[d].push_back(t);
    d=1-d;
  }
  int g=8000;
  int dx[2][2*8000]={},dy[2][2*8000]={};
  dx[0][g]=dy[0][g]=1;
  rep(i,a[0].size())rep(j,2*g)if(dx[i%2][j]){
    dx[(i+1)%2][j+a[0][i]]=1;
    if(i>0)dx[(i+1)%2][j-a[0][i]]=1;
    dx[i%2][j]=0;
  }
  rep(i,a[1].size())rep(j,2*g)if(dy[i%2][j]){
    dy[(i+1)%2][j+a[1][i]]=1;
    dy[(i+1)%2][j-a[1][i]]=1;
    dy[i%2][j]=0;
  }
  if(dx[(int)(a[0].size())%2][x+g] && dy[(int)(a[1].size())%2][y+g])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Submission Info

Submission Time
Task D - FT Robot
User rika0384
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1328 Byte
Status
Exec Time 85 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 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 1 ms 512 KB
0_01.txt 1 ms 512 KB
0_02.txt 1 ms 512 KB
0_03.txt 1 ms 512 KB
0_04.txt 1 ms 512 KB
0_05.txt 1 ms 512 KB
1_00.txt 2 ms 512 KB
1_01.txt 2 ms 512 KB
1_02.txt 2 ms 512 KB
1_03.txt 2 ms 512 KB
1_04.txt 2 ms 512 KB
1_05.txt 2 ms 512 KB
1_06.txt 47 ms 512 KB
1_07.txt 47 ms 512 KB
1_08.txt 61 ms 512 KB
1_09.txt 61 ms 512 KB
1_10.txt 60 ms 512 KB
1_11.txt 60 ms 512 KB
1_12.txt 31 ms 512 KB
1_13.txt 31 ms 512 KB
1_14.txt 46 ms 512 KB
1_15.txt 46 ms 512 KB
1_16.txt 45 ms 512 KB
1_17.txt 45 ms 512 KB
1_18.txt 46 ms 512 KB
1_19.txt 46 ms 512 KB
1_20.txt 46 ms 512 KB
1_21.txt 47 ms 512 KB
1_22.txt 47 ms 512 KB
1_23.txt 46 ms 512 KB
1_24.txt 47 ms 512 KB
1_25.txt 46 ms 512 KB
1_26.txt 83 ms 512 KB
1_27.txt 85 ms 512 KB
1_28.txt 46 ms 512 KB
1_29.txt 46 ms 512 KB
1_30.txt 25 ms 512 KB
1_31.txt 24 ms 512 KB
1_32.txt 14 ms 512 KB
1_33.txt 13 ms 512 KB
1_34.txt 8 ms 512 KB
1_35.txt 7 ms 512 KB
1_36.txt 5 ms 512 KB
1_37.txt 5 ms 512 KB
1_38.txt 3 ms 512 KB
1_39.txt 3 ms 512 KB
1_40.txt 2 ms 512 KB
1_41.txt 2 ms 512 KB
1_42.txt 37 ms 512 KB
1_43.txt 36 ms 512 KB
1_44.txt 41 ms 512 KB
1_45.txt 44 ms 512 KB
1_46.txt 32 ms 512 KB
1_47.txt 40 ms 512 KB
1_48.txt 37 ms 512 KB
1_49.txt 44 ms 512 KB