QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648306 | #6422. Evil Coordinate | shabi666 | WA | 132ms | 3952kb | C++20 | 1.7kb | 2024-10-17 18:13:01 | 2024-10-17 18:13:02 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 1e6 + 5;
bool check(string path, int x, int y) {
int xx = 0, yy = 0;
for (char c : path) {
if (c == 'U')
yy++;
if (c == 'D')
yy--;
if (c == 'L')
xx--;
if (c == 'R')
xx++;
if (xx == x && yy == y) {
return false;
}
}
return true;
}
void solve() {
int x, y;
cin >> x >> y;
string s;
cin >> s;
map<char, int> cnt;
int ex = 0, ey = 0;
for (char c : s) {
cnt[c]++;
}
ey = cnt['U'] - cnt['D'];
ex = cnt['R'] - cnt['L'];
if (x == 0 && y == 0 || x == ex && y == ey) {
cout << "Impossible" << endl;
return;
}
if ( ex == 0 || ey == 0 ) {
if ( cnt['L'] == 0 && cnt['R'] == 0 ) {
if (x == ex && abs(y) <= abs(ey) && y * ey >= 0 ) {
cout << "Impossible" << endl;
return;
}
} else if ( cnt['U'] == 0 && cnt['D'] == 0 ) {
if (y == ey && abs(x) <= abs(ex) && x * ex >= 0 ) {
cout << "Impossible" << endl;
return;
}
}
}
srand(time(0));
random_shuffle(s.begin(), s.end());
int t = rand() % 100;
while (t--) {
random_shuffle(s.begin(), s.end());
}
cout << s << endl;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--) solve();
//check("RRUUUUUUUURLRLRLUDUDUD", 4, 1);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
LRULDUR UUU Impossible Impossible Impossible
result:
ok 5 cases
Test #2:
score: -100
Wrong Answer
time: 132ms
memory: 3952kb
input:
11109 6 0 RUDUDR 2 0 URU 0 0 UDRU 0 0 R -1 1 LDUUDDRUUL -1 5 RRUUUDUUU -8 4 RRDRLDR 2 0 UD 0 0 UUDD 3 -2 LDDLLLRR 3 -2 LDRURLDD 1 0 RRL -1 0 DUDDLLRDU -4 0 LL -1 -1 DLRLDLUDUR 1 4 URDULUR 0 0 DDUUDUDDDD 0 2 UU 1 0 RRULD 0 -2 LDLRLLDRRL 0 1 RLRLLRLUR -3 0 RL 0 0 D 0 0 L 0 0 DDLRRUDRUD 0 0 DULU 2 0 RR...
output:
RDUURD RUU Impossible Impossible Impossible UURDUUURU DDRLRRR UD Impossible LLDRDLLR RLRDDLUD Impossible DDDLLUDUR LL Impossible UDRLRUU Impossible Impossible Impossible DRLLLDRRLL Impossible RL Impossible Impossible Impossible Impossible Impossible LRUULRRRRL DLLLU Impossible LDUDUDU RDUUDR Impossi...
result:
wrong answer case 20, participant's output goes through forbidden coordinate