結果
| 問題 |
No.8069 Torn Documents
|
| コンテスト | |
| ユーザー |
mtsd
|
| 提出日時 | 2020-04-01 22:15:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,100 bytes |
| コンパイル時間 | 1,081 ms |
| コンパイル使用メモリ | 123,580 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-21 21:38:34 |
| 合計ジャッジ時間 | 3,645 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 15 |
ソースコード
#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;
}
mtsd