QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506631 | #6422. Evil Coordinate | 122 | WA | 0ms | 3544kb | C++14 | 1.4kb | 2024-08-05 20:19:25 | 2024-08-05 20:19:27 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define maxn 100+5
#define int long long
using namespace std;
signed main() {
IOS
int t;
cin >> t;
string s = "UDLR";
while (t--) {
int x, y;
vector<int> cnt(4, 0);
cin >> x >> y;
string str;
cin >> str;
for (char c : str) {
if (c == 'U') cnt[0]++;
else if (c == 'D') cnt[1]++;
else if (c == 'L') cnt[2]++;
else if (c == 'R') cnt[3]++;
}
int up = cnt[0], down = cnt[1], left = cnt[2], right = cnt[3];
down = -down;
left = -left;
bool possible = true;
// Check if the net vertical movement can match y
if (y > 0 && up < y) possible = false;
if (y < 0 && down > y) possible = false;
// Check if the net horizontal movement can match x
if (x > 0 && right < x) possible = false;
if (x < 0 && left > x) possible = false;
if (!possible) {
cout << "Impossible" << endl;
continue;
}
// Construct the path
string path;
if (x > 0) while (x--) path.push_back('R');
if (x < 0) while (x++) path.push_back('L');
if (y > 0) while (y--) path.push_back('U');
if (y < 0) while (y++) path.push_back('D');
cout << path << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
RLUD Impossible UUUD UUD
result:
wrong answer case 1, participant's output is not a permutation of the input