提出 #2149177


ソースコード 拡げる

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);
    
    map<int, bool> dp1, dp2;
    bool t = false, yoko = true;
    int k = 0;
    dp1[0] = true;dp2[0] = true;
    REP(i, s.size()){
        if(s[i] == 'F'){
            k++;
        }
        else{
            if(t){
                if(yoko){
                    for(int i = -8000; i <= 8000; i++){
                        if(dp1[i]){
                            dp1[i - k] = true;
                            dp1[i + k] = true;
                        }
                    }
                    yoko = false;
                }
                else{
                    for(int i = -8000; i <= 8000; i++){
                        if(dp2[i]){
                            dp2[i - k] = true;
                            dp2[i + k] = true;
                        }
                    }
                    yoko = true;
                }
            }
            else{
                dp1[-k] = true;
                dp1[k] = true;
                yoko = false;
            }
            t = true;
            k = 0;
        }
    }
    if(s[s.size() - 1] == 'F'){
        if(yoko){
            for(int i = -8000; i <= 8000; i++){
                if(dp1[i]){
                    dp1[i - k] = true;
                    dp1[i + k] = true;
                }
            }
        }
        else{
            for(int i = -8000; i <= 8000; i++){
                if(dp2[i]){
                    dp2[i - k] = true;
                    dp2[i + k] = true;
                }
            }
        }
    }
    
    if(dp1[x] & dp2[y]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

提出情報

提出日時
問題 D - FT Robot
ユーザ chocobo
言語 C++14 (GCC 5.4.1)
得点 0
コード長 2350 Byte
結果
実行時間 2103 ms
メモリ 1792 KB

コンパイルエラー

./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);
                           ^

テストケース

セット名 得点 / 配点 テストケース
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
ケース名 結果 実行時間 メモリ
0_00.txt 7 ms 1792 KB
0_01.txt 7 ms 1792 KB
0_02.txt 4 ms 1024 KB
0_03.txt 4 ms 1024 KB
0_04.txt 6 ms 1792 KB
0_05.txt 7 ms 1792 KB
1_00.txt 4 ms 1024 KB
1_01.txt 4 ms 1024 KB
1_02.txt 4 ms 1024 KB
1_03.txt 4 ms 1024 KB
1_04.txt 6 ms 1792 KB
1_05.txt 6 ms 1792 KB
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 966 ms 1792 KB
1_35.txt 921 ms 1792 KB
1_36.txt 513 ms 1792 KB
1_37.txt 607 ms 1792 KB
1_38.txt 242 ms 1792 KB
1_39.txt 270 ms 1792 KB
1_40.txt 118 ms 1792 KB
1_41.txt 143 ms 1792 KB
1_42.txt
1_43.txt
1_44.txt
1_45.txt
1_46.txt
1_47.txt
1_48.txt
1_49.txt