結果

問題 No.8069 Torn Documents
ユーザー betrue12
提出日時 2020-04-01 23:06:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 204,888 KB
最終ジャッジ日時 2025-01-09 12:21:47
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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;
            passed.emplace(x, y);
        }
    }
    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