結果

問題 No.3069 Torn Documents
ユーザー betrue12betrue12
提出日時 2020-04-01 23:03:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 841 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 208,788 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 02:54:18
合計ジャッジ時間 5,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    vector<int> S;
    int dx[] = {0, 0, -1, 1};
    int dy[] = {-1, 1, 0, 0};
    string LRUD = "LRUD";
    string str;
    cin >> str;
    for(char c : str) S.push_back(LRUD.find(c));
    vector<pair<int, int>> ans;
    
    int x = A, y = B;
    set<pair<int, int>> passed;
    passed.emplace(x, y);
    for(int k : S){
        int x2 = x+dx[k], y2 = y+dy[k];
        if(x2 < 0 || y2 < 0) continue;
        if(k%2 && !passed.count({x2, y2})){
            ans.emplace_back(x2, y2);
        }else{
            x = x2;
            y = y2;
        }
    }
    if(x == 0 && y == 0){
        cout << ans.size() << endl;
        for(auto& p : ans) cout << p.first << " " << p.second << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}
0