結果

問題 No.3069 Torn Documents
ユーザー mtsdmtsd
提出日時 2020-04-01 22:15:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,100 bytes
コンパイル時間 1,220 ms
コンパイル使用メモリ 121,536 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-29 02:53:36
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,384 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 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
set<pair<int,int> >st;
set<pair<int,int> >used;
int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    int n = s.size();
    used.insert(MP(a,b));
    rep(i,n){
        if(s[i]=='L'){
            if(b==0)continue;
            if(st.count(MP(a,b-1))==0){
                b--;
                used.insert(MP(a,b));
            }
        }else if(s[i]=='U'){
            if(a==0)continue;
            if(st.count(MP(a-1,b))==0){
                a--;
                used.insert(MP(a,b));
            }
        }else if(s[i]=='R'){
            if(used.count(MP(a,b+1))){
                b++;
            }else{
                st.insert(MP(a,b+1));
            }
        }else{
            if(used.count(MP(a+1,b))){
                a++;
            }else{
                st.insert(MP(a+1,b));
            }
        }
    }
    if(a==0&&b==0){
        cout << st.size() << "\n";
        for(auto x:st){
            cout << x.first << " " << x.second << "\n";
        }
    }else{
        cout << -1 << endl;
    }
    return 0;
}
0