Submission #5020601


Source Code Expand

Copy
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;
  ll x, y;
  cin >> x >> y;

  vll x_jump;
  vll y_jump;
  ll x_count = 0;
  ll y_count = 0;
  bool x_flag = true;
  for(ll i=0; i<S.size(); ++i){
    if(S[i]=='T'){
      x_flag = !x_flag;
      if(x_count>0) x_jump.push_back(x_count);
      if(y_count>0) y_jump.push_back(y_count);
      x_count = 0;
      y_count = 0;
    }else if(S[i]=='F'){
      if(x_flag) x_count++;
      else y_count++;
    }
  }
  if(x_count>0) x_jump.push_back(x_count);
  if(y_count>0) y_jump.push_back(y_count);

  vb dpx1(10000, false);
  vb dpy1(10000, false);
  dpx1[0] = true;
  dpy1[0] = true;
  for(ll i=0; i<x_jump.size(); ++i){
    vb dpx(10000, false);
    for(ll j=0; j<10000; ++j){
      if(dpx1[j]){
        dpx[abs(j+x_jump[i])]=true;
        dpx[abs(j-x_jump[i])]=true;
      }
    }
    dpx1 = dpx;
  }
  for(ll i=0; i<y_jump.size(); ++i){
    vb dpy(10000, false);
    for(ll j=0; j<10000; ++j){
      if(dpy1[j]){
        dpy[abs(j+y_jump[i])]=true;
        dpy[abs(j-y_jump[i])]=true;
      }
    }
    dpy1 = dpy;
  }

  if(dpx1[abs(x)] && dpy1[abs(y)]){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }


  return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User fockl
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3391 Byte
Status
Exec Time 46 ms
Memory 384 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 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
0_03.txt 1 ms 256 KB
0_04.txt 1 ms 256 KB
0_05.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 1 ms 256 KB
1_04.txt 1 ms 256 KB
1_05.txt 1 ms 256 KB
1_06.txt 46 ms 384 KB
1_07.txt 46 ms 384 KB
1_08.txt 32 ms 384 KB
1_09.txt 32 ms 384 KB
1_10.txt 32 ms 384 KB
1_11.txt 32 ms 384 KB
1_12.txt 30 ms 384 KB
1_13.txt 30 ms 256 KB
1_14.txt 24 ms 256 KB
1_15.txt 24 ms 256 KB
1_16.txt 24 ms 256 KB
1_17.txt 24 ms 256 KB
1_18.txt 23 ms 256 KB
1_19.txt 23 ms 256 KB
1_20.txt 24 ms 256 KB
1_21.txt 23 ms 256 KB
1_22.txt 24 ms 256 KB
1_23.txt 23 ms 256 KB
1_24.txt 23 ms 256 KB
1_25.txt 24 ms 256 KB
1_26.txt 1 ms 256 KB
1_27.txt 1 ms 256 KB
1_28.txt 23 ms 256 KB
1_29.txt 23 ms 256 KB
1_30.txt 19 ms 256 KB
1_31.txt 18 ms 256 KB
1_32.txt 12 ms 256 KB
1_33.txt 12 ms 256 KB
1_34.txt 7 ms 256 KB
1_35.txt 6 ms 256 KB
1_36.txt 4 ms 256 KB
1_37.txt 5 ms 256 KB
1_38.txt 3 ms 256 KB
1_39.txt 3 ms 256 KB
1_40.txt 2 ms 256 KB
1_41.txt 2 ms 256 KB
1_42.txt 16 ms 256 KB
1_43.txt 16 ms 256 KB
1_44.txt 16 ms 256 KB
1_45.txt 16 ms 256 KB
1_46.txt 16 ms 256 KB
1_47.txt 16 ms 256 KB
1_48.txt 16 ms 256 KB
1_49.txt 16 ms 256 KB