Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <unordered_map>
using namespace std;

struct St {
    string s;
    int degree;
    int x;
    int y;
    St(string s, int degree, int x, int y){
        this->s = s;
        this->degree = degree;
        this->x = x;
        this->y = y;
    }
};

unordered_map<St, bool> map;

int countF(string s){
    int count = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'F')
            count++;
    }
    return count;
}

int countT(string s){
    return s.size() - countF(s);
}

int countVertical(string s, int degree) {
    bool flag;
    if(degree%180 == 0)
        flag = false;
    else
        flag = true;
    int count = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'T')
            flag = !flag;
        else {
            if(flag)
                count++;
        }
    }
    return count;
}

bool execute(string s, int degree, long long dx, long long dy, long long countf, long long countv) {
    St st = St(s,degree,dx,dy);
    if (map.find(st) != map.end()){
        return map[st];
    }
    if(s == ""){
        if(dx ==0 && dy==0){
            return true;
        }
        else{
            return false;
        }
    }

    // pruning!!
    int countt = s.size() - countf;
    if (countv < abs(dy))
        return false;
    int h = countf- countv;
    if (h < abs(dx)){
        return false;
    }
    if(degree == 0 && countt < 2 && dx < 0)
        return false;
    if(degree == 180 && countt < 2 && dx > 0)
        return false;
    if(degree == 90 && countt < 2 && dy < 0)
        return false;
    if(degree == 270 && countt < 2 && dy > 0)
        return false;

    string next = s.substr(1);
    if(s[0] == 'F'){
        if(degree==0){
            map[st] = execute(next, degree, dx-1,dy,countf-1,countv);
            return map[st];
        }
        else if (degree == 90){
            map[st] =  execute(next, degree,dx, dy-1,countf-1,countv-1);
            return map[st];
        }
        else if (degree == 180){
            map[st]  = execute(next, degree,dx+1, dy,countf-1,countv);
            return map[st];
        }
        else{
            map[st] = execute(next, degree,dx,dy+1,countf-1,countv-1);
            return map[st];
        }
    } else {
        int minusdegree = degree - 90;
        int plusdegree = degree + 90;
        if(minusdegree < 0)
            minusdegree += 360;
        if(plusdegree >= 360)
            plusdegree -= 360;
        bool p =  execute(next, plusdegree, dx,dy,countf,countv);
        if(p){
            map[st] = p;
            return p;
        }
        bool m =  execute(next,minusdegree,dx,dy,countf,countv);
        map[st] = m;
        return m;
    }
}


int main(){
    string s;
    long long x,y;
    cin >> s >> x >> y;
    int v = countVertical(s, 0);
    int f = countF(s);
    int h = f - v;
    if (v%2 != abs(y)%2){
        cout << "No" << endl;
        return 0;
    }
    if (h%2 != abs(x)%2){
        cout << "No" << endl;
        return 0;
    }
    if(execute(s, 0, x, y, f, v))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Compiler output:
a.cc:21:25: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = St; _Tp = bool; _Hash = std::hash<St>; _Pred = std::equal_to<St>; _Alloc = std::allocator<std::pair<const St, bool> >]'
   21 | unordered_map<St, bool> map;
      |                         ^~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:5:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = St; _Tp = bool; _Hash = std::hash<St>; _Pred = std::equal_to<St>; _Alloc = std::allocator<std::pair<const St, bool> >]' is implicitly deleted because the default definition would be ill-formed:
  148 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = St; _Value = std::pair<const St, bool>; _Alloc = std::allocator<std::pair<const St, bool> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<St>; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = St; _Value = std::pair<const St, bool>; _Alloc = std::allocator<std::pair<const St, bool> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<St>; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
  539 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = St; _Value = std::pair<const St, bool>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<St>; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = St; _Value = std::pair<const St, bool>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<St>; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
 1731 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = St; _Value = std::pair<const St, bool>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<St>]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7:   required from here
 1328 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<St>::hash()'
 1245 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<St>::hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<St, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = St; bool <anonymous> = false]'
   83 |       __hash_enum(__hash_enum&&);
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = St; bool <anonymous> = false]' is private within this context
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
 1245 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = St; _Value = std::pair<const St, bool>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<St>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
 1328 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<St>, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<St>, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
 1242 |     struct _Hashtable_ebo_helper<_Nm, _Tp, true>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<St>::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<St>::~hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = St; bool <anonymous> = false]' is private within this context
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
 1731 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<St, std::pair<const St, bool>, std::__detail::_Select1st, std::hash<St>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<St, std::pair<const St, bool>, std::__detail::_Select1st, std::hash<St>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
 1306 |     struct _Hash_code_base
      |            ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<St>, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
  539 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<St, std::pair<const St, bool>, std::__detail::_Select1st, std::equal_to<St>, std::hash<St>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1688:12: note: 'std::__detail::_Hashtable_base<St, std::pair<const St, bool>, std::__detail::_Select1st, std::equal_to<St>, std::hash<St>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
 1688 |     struct _Hashtable_base
      |            ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1688:12: error: use of deleted function 'std::__detail::_Hash_code_base<St, std::pair<const St, bool>, std::_