Submission #6303983


Source Code Expand

Copy
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

string s;
int x,y;

bool check(int s, int t, vector<int> v, bool isX = true) {
  vector<vector<bool>> dp(2,vector<bool>(16010,false));
  int cur = 0, nxt = 1;
  dp[cur][s+8000] = true;
  REP(i,v.size()) {
    fill(ALL(dp[nxt]),false);
    REP(j,16010) if (dp[cur][j]) {
      if (i == 0 && isX) {
        dp[nxt][j+v[i]] = true;
      } else {
        dp[nxt][j-v[i]] = dp[nxt][j+v[i]] = true;
      }
    }
    swap(cur,nxt);
  }
  return dp[cur][t+8000];
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> s >> x >> y;
  s += "T";
  vector<int> v[2];
  int p = 0, c = 0;
  REP(i,s.size()) {
    if (s[i] == 'T') {
      v[p].push_back(c);
      c = 0;
      p ^= 1;
    } else {
      c++;
    }
  }
  cout << (check(0,x,v[0]) && check(0,y,v[1],false) ? "Yes" : "No") << endl;

  return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User mathlegosuke
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1912 Byte
Status
Exec Time 124 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 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 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 72 ms 384 KB
1_07.txt 37 ms 384 KB
1_08.txt 93 ms 384 KB
1_09.txt 50 ms 384 KB
1_10.txt 93 ms 384 KB
1_11.txt 43 ms 384 KB
1_12.txt 47 ms 384 KB
1_13.txt 47 ms 384 KB
1_14.txt 69 ms 384 KB
1_15.txt 69 ms 384 KB
1_16.txt 69 ms 384 KB
1_17.txt 69 ms 384 KB
1_18.txt 71 ms 384 KB
1_19.txt 36 ms 384 KB
1_20.txt 71 ms 384 KB
1_21.txt 37 ms 384 KB
1_22.txt 72 ms 384 KB
1_23.txt 71 ms 384 KB
1_24.txt 72 ms 384 KB
1_25.txt 71 ms 384 KB
1_26.txt 124 ms 384 KB
1_27.txt 64 ms 384 KB
1_28.txt 71 ms 384 KB
1_29.txt 37 ms 384 KB
1_30.txt 39 ms 256 KB
1_31.txt 19 ms 256 KB
1_32.txt 21 ms 256 KB
1_33.txt 20 ms 256 KB
1_34.txt 11 ms 256 KB
1_35.txt 6 ms 256 KB
1_36.txt 6 ms 256 KB
1_37.txt 4 ms 256 KB
1_38.txt 4 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 26 ms 256 KB
1_43.txt 25 ms 256 KB
1_44.txt 35 ms 256 KB
1_45.txt 56 ms 384 KB
1_46.txt 46 ms 384 KB
1_47.txt 24 ms 384 KB
1_48.txt 24 ms 256 KB
1_49.txt 24 ms 384 KB