Submission #3027482


Source Code Expand

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

bool check(vector<int> vi, int n) {
    queue<int> q;
    q.push(vi[0]);
    FOR(i, 1, vi.size()) {
        int size = q.size();
        REP(j, size) {
            int n = q.front(); q.pop();
            q.push(n + vi[i]);
            q.push(n - vi[i]);
        }
    }
    bool ok = false;
    while (!q.empty()) {
        ok |= q.front() == n;
        q.pop();
    }
    return ok;
}

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    s += 'T';
    vector<int> hv, vv;
    int count = 0;
    bool horizontal = true;
    REP(i, s.length()) {
        if (s[i] == 'T') {
            if (horizontal) hv.push_back(count);
            else vv.push_back(count);
            horizontal = !horizontal;
            count = 0;
        }
        else count++;
    }

    bool ok = false;
    if (check(hv, x)){
        ok |= check(vv, y);
        vv[0] *= -1;
        ok |= check(vv, y);
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Submission Info

Submission Time
Task D - FT Robot
User shiita0903
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1508 Byte
Status RE
Exec Time 2173 ms
Memory 1161492 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 6
AC × 11
TLE × 44
RE × 1
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt
All 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 AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
0_04.txt AC 1 ms 256 KB
0_05.txt AC 1 ms 256 KB
1_00.txt RE 97 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt TLE 2171 ms 1127288 KB
1_07.txt TLE 2170 ms 1127736 KB
1_08.txt TLE 2171 ms 1154992 KB
1_09.txt TLE 2173 ms 1154676 KB
1_10.txt TLE 2172 ms 1156340 KB
1_11.txt TLE 2172 ms 1156072 KB
1_12.txt TLE 2172 ms 1129096 KB
1_13.txt TLE 2173 ms 1132312 KB
1_14.txt TLE 2171 ms 1127816 KB
1_15.txt TLE 2171 ms 1130180 KB
1_16.txt TLE 2173 ms 1130748 KB
1_17.txt TLE 2170 ms 1130004 KB
1_18.txt TLE 2172 ms 1130496 KB
1_19.txt TLE 2170 ms 1132160 KB
1_20.txt TLE 2173 ms 1134720 KB
1_21.txt TLE 2173 ms 1161492 KB
1_22.txt TLE 2172 ms 1158056 KB
1_23.txt TLE 2172 ms 1159396 KB
1_24.txt TLE 2173 ms 1135776 KB
1_25.txt TLE 2170 ms 1134648 KB
1_26.txt TLE 2173 ms 1156664 KB
1_27.txt TLE 2170 ms 1153860 KB
1_28.txt TLE 2171 ms 1133232 KB
1_29.txt TLE 2173 ms 1161168 KB
1_30.txt TLE 2172 ms 1131144 KB
1_31.txt TLE 2173 ms 1128360 KB
1_32.txt TLE 2169 ms 1120540 KB
1_33.txt TLE 2172 ms 1121696 KB
1_34.txt TLE 2171 ms 1122208 KB
1_35.txt TLE 2170 ms 1119616 KB
1_36.txt TLE 2171 ms 1123888 KB
1_37.txt TLE 2170 ms 1121232 KB
1_38.txt TLE 2170 ms 1120728 KB
1_39.txt TLE 2171 ms 1122704 KB
1_40.txt TLE 2170 ms 1104140 KB
1_41.txt TLE 2170 ms 1118424 KB
1_42.txt TLE 2170 ms 1132692 KB
1_43.txt TLE 2170 ms 1129904 KB
1_44.txt TLE 2170 ms 1129608 KB
1_45.txt TLE 2171 ms 1135696 KB
1_46.txt TLE 2170 ms 1130296 KB
1_47.txt TLE 2171 ms 1133180 KB
1_48.txt TLE 2171 ms 1130240 KB
1_49.txt TLE 2170 ms 1133824 KB