結果
| 問題 |
No.8069 Torn Documents
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-01 23:18:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,516 bytes |
| コンパイル時間 | 2,232 ms |
| コンパイル使用メモリ | 201,340 KB |
| 最終ジャッジ日時 | 2025-01-09 12:24:14 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 15 |
ソースコード
#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));
int N = S.size();
int lastR = -1, lastD = -1;
for(int i=0; i<N; i++){
if(str[i] == 'D') lastD = i;
if(str[i] == 'R') lastR = i;
}
for(int b1=0; b1<2; b1++) for(int b2=0; b2<2; b2++){
set<pair<int, int>> ans;
int x = A, y = B;
set<pair<int, int>> passed;
passed.emplace(x, y);
for(int i=0; i<N; i++){
int k = S[i];
int x2 = x+dx[k], y2 = y+dy[k];
if(x2 < 0 || y2 < 0) continue;
if(ans.count({x2, y2})) continue;
bool move;
if(b1 && lastD == i){
move = true;
}else if(b2 && lastR == i){
move = true;
}else if(k%2 && !passed.count({x2, y2})){
move = false;
ans.emplace(x2, y2);
}else{
move = true;
}
if(move){
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;
return 0;
}
}
cout << -1 << endl;
return 0;
}