結果

問題 No.3069 Torn Documents
ユーザー やむなくやむなく
提出日時 2020-04-01 06:14:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,919 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 181,788 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 02:52:18
合計ジャッジ時間 3,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    int n = s.size();

    int pre = 0;
    string t;
    map<char, int> type = {
            {'L', 1},
            {'R', 1},
            {'D', 2},
            {'U', 2}
    };
    for(int i = n - 1; i >= 0; i--){
        if(type[s[i]] == pre) continue;
        t.push_back(s[i]);
        pre = type[s[i]];
    }

    map<char, bool> flag;
    for(auto &c : t) flag[c] = true;

    if(!flag['L'] || !flag['U']){
        cout << -1 << endl;
        return 0;
    }

    if(t[0] == 'L'){
        cout << 6 << endl;
        cout << 0 << " " << b+2 << endl;
        cout << 1 << " " << 0 << endl;
        cout << 1 << " " << b+1 << endl;
        cout << a << " " << b-1 << endl;
        cout << a << " " << b+1 << endl;
        cout << a+1 << " " << b << endl;
    }else if(t[0] == 'U'){
        cout << 6 << endl;
        cout << 0 << " " << 1 << endl;
        cout << a+1 << " " << 1 << endl;
        cout << a-1 << " " << b << endl;
        cout << a << " " << b+1 << endl;
        cout << a+1 << " " << b << endl;
        cout << a+2 << " " << 0 << endl;
    }else{
        if(t[1] == 'L'){
            cout << 6 << endl;
            cout << 0 << " " << b+2 << endl;
            cout << 1 << " " << 0 << endl;
            cout << 1 << " " << b+1 << endl;
            cout << a << " " << b-1 << endl;
            cout << a << " " << b+1 << endl;
            cout << a+1 << " " << b << endl;
        }else if(t[1] == 'U'){
            cout << 6 << endl;
            cout << 0 << " " << 1 << endl;
            cout << a+1 << " " << 1 << endl;
            cout << a-1 << " " << b << endl;
            cout << a << " " << b+1 << endl;
            cout << a+1 << " " << b << endl;
            cout << a+2 << " " << 0 << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}
0