Submission #3414130


Source Code Expand

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

const int N = (8000 + 5) * 2;
bool dp[N][N];
bool fn(vector<int> v, int x)
{
  const int base = N / 2;
  fill(&dp[0][0], &dp[N - 1][N - 1] + 1, false);
  dp[0][base] = true;
  for (int i = 0; i < v.size(); ++i) {
    for (int j = 0; j < N; ++j) {
      if (dp[i][j]) {
        dp[i + 1][j + v[i]] = true;
        dp[i + 1][j - v[i]] = true;
      }
    }
  }

  return dp[v.size()][x + base];
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  int x, y;
  while (cin >> s >> x >> y) {
    vector<int> v;
    int cnt = 0;
    each (c, s) {
      if (c == 'T') {
        v.push_back(cnt);
        cnt = 0;
      }
      if (c == 'F') {
        ++cnt;
      }
    }
    v.push_back(cnt);

    vector<int> a;
    vector<int> b;
    for (int i = 1; i < v.size(); ++i) {
      if (i % 2 == 0) a.push_back(v[i]);
      else b.push_back(v[i]);
    }

    bool f = fn(a, x - v.front()) && fn(b, y);
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User Johniel
Language C++ (GCC 5.4.1)
Score 0
Code Size 1177 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:37:11: error: ISO C++ forbids declaration of ‘c’ with no type [-fpermissive]
     each (c, s) {
           ^
./Main.cpp:3:31: note: in definition of macro ‘each’
 #define each(i, c) for (auto& i : c)
                               ^
./Main.cpp:37:14: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
     each (c, s) {
              ^
./Main.cpp:3:35: note: in definition of macro ‘each’
 #define each(i, c) for (auto& i : c)
                                   ^