Submission #2149404


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main() {
    string s;
    int x, y;
    
    cin >> s;
    scanf("%d %d", &x, &y);
    
    int xx = 0, yy = 0, d[8005] = {}, p = 0;
    bool yoko = true;
    REP(i, s.size()){
        if(s[i] == 'F'){
            d[p]++;
            if(yoko){
                xx++;
            }
            else{
                yy++;
            }
        }
        else{
            yoko = !yoko;
            p++;
        }
    }
    
    map<int, bool> dp1, dp2;
    dp1[d[0]] = true;dp2[0] = true;
    for(int i = 1; i <= p; i++){
        if(i % 2 == 0){
            for(int j = -xx; j <= xx; j++){
                if(dp1[j - d[i]] || dp1[j + d[i]]){
                    dp1[j] = true;
                }
                else{
                    dp1[j] = false;
                }
            }
        }
        else{
            for(int j = -yy; j <= yy; j++){
                if(dp2[j - d[i]] || dp2[j + d[i]]){
                    dp2[j] = true;
                }
                else{
                    dp2[j] = false;
                }
            }
        }
    }
    
    /*
    for(int i = -xx; i <= xx; i++){
        cout << dp1[i] << ' ';
    }
    cout << endl;
    for(int i = -yy; i <= yy; i++){
        cout << dp2[i] << ' ';
    }
    cout << endl;
    */
    
    if(dp1[x] & dp2[y]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Submission Info

Submission Time
Task D - FT Robot
User chocobo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2028 Byte
Status
Exec Time 2103 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
                           ^

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 7 ms 1792 KB
1_03.txt 7 ms 1792 KB
1_04.txt 7 ms 1792 KB
1_05.txt 7 ms 1792 KB
1_06.txt 1839 ms 640 KB
1_07.txt 1840 ms 640 KB
1_08.txt 1534 ms 512 KB
1_09.txt 1534 ms 512 KB
1_10.txt 1570 ms 512 KB
1_11.txt 1569 ms 512 KB
1_12.txt 1955 ms 768 KB
1_13.txt 1955 ms 768 KB
1_14.txt
1_15.txt
1_16.txt
1_17.txt
1_18.txt 1806 ms 640 KB
1_19.txt 1810 ms 640 KB
1_20.txt 1784 ms 640 KB
1_21.txt 1852 ms 640 KB
1_22.txt 1827 ms 640 KB
1_23.txt 1829 ms 640 KB
1_24.txt 1810 ms 640 KB
1_25.txt 1871 ms 640 KB
1_26.txt 2 ms 256 KB
1_27.txt 2 ms 256 KB
1_28.txt 1823 ms 640 KB
1_29.txt 1838 ms 640 KB
1_30.txt 1393 ms 768 KB
1_31.txt 1354 ms 896 KB
1_32.txt 864 ms 896 KB
1_33.txt 818 ms 896 KB
1_34.txt 428 ms 1024 KB
1_35.txt 415 ms 1024 KB
1_36.txt 231 ms 1024 KB
1_37.txt 281 ms 1024 KB
1_38.txt 116 ms 1024 KB
1_39.txt 130 ms 1024 KB
1_40.txt 58 ms 1024 KB
1_41.txt 70 ms 1152 KB
1_42.txt 1643 ms 896 KB
1_43.txt 1684 ms 896 KB
1_44.txt 1594 ms 768 KB
1_45.txt 1674 ms 896 KB
1_46.txt
1_47.txt 1611 ms 896 KB
1_48.txt 1606 ms 896 KB
1_49.txt 1623 ms 896 KB