結果
問題 |
No.8069 Torn Documents
|
ユーザー |
|
提出日時 | 2020-04-01 23:03:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 841 bytes |
コンパイル時間 | 2,587 ms |
コンパイル使用メモリ | 204,708 KB |
最終ジャッジ日時 | 2025-01-09 12:21:31 |
ジャッジサーバー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)); 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; }