QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506153 | #6422. Evil Coordinate | 122 | WA | 0ms | 3592kb | C++14 | 2.2kb | 2024-08-05 15:43:56 | 2024-08-05 15:43:57 |
Judging History
answer
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cstring>
#include<ctype.h>
#include<set>
#include<map>
#include<cmath>
#include<climits>
#include<stack>
#include<list>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define maxn 100+5
#define ll long long
using namespace std;
const int mod = 1e8;
signed main() {
int t;
cin >> t;
string s = "UDLR";
while (t--)
{
int x, y;
vector<int>cnt(5, 0);
cin >> x >> y;
string str;
cin >> str;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == s[0])
cnt[0]++;
if (str[i] == s[1])
cnt[1]++;
if (str[i] == s[2])
cnt[2]++;
if (str[i] == s[3])
cnt[3]++;
}
int up = cnt[0]; int down = cnt[1]; int left = cnt[2]; int right = cnt[3];
down = -down; left = -left;
bool flag1 = true;
bool flag2 = true;
int len = str.size();
int a = 0;
int b = 0;
string path;
if (x == 0 && y == 0)
{
cout << "Impossible"<<endl;
continue;
}
if (up + down == y&&left+right==x)
{
cout << "Impossible"<<endl;
continue;
}
if (up > y && down == 0 && left == 0 && right == 0 ||
(down < y && up == 0 && left == 0 && right == 0) ||
(left < x && down == 0 && up == 0 && right == 0) ||
(right > x && up == 0 && down == 0 && left == 0))
{
cout << "Impossible" << endl;
continue;
}
/*cout << up << " " << down << endl;*/
if (up + down != y)
{
while (up)
{
up--;
path.push_back(s[0]);
}
while (down<0)
{
down++;
path.push_back(s[1]);
}
while (left<0)
{
left++;
path.push_back(s[2]);
}
while (right)
{
right--;
path.push_back(s[3]);
}
cout << path << endl;
continue;
}
cout << left << " " << right << endl;
if (left + right != x)
{
while (left <0)
{
left++;
path.push_back(s[2]);
}
while (right)
{
right--;
path.push_back(s[3]);
}
while (up)
{
up--;
path.push_back(s[0]);
}
while (down < 0)
{
down++;
path.push_back(s[1]);
}
cout << path << endl;
continue;
}
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3592kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
-2 2 LLRRUUD UUU Impossible Impossible Impossible
result:
wrong answer Line "-2 2" doesn't correspond to pattern "[UDLR]{1,100000}|Impossible"