QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691454#6422. Evil Coordinateyzj123#WA 11ms3824kbC++203.1kb2024-10-31 11:30:322024-10-31 11:30:34

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 11:30:34]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3824kb
  • [2024-10-31 11:30:32]
  • 提交

answer

#include<bits/stdc++.h>
using i64 = long long;
const int inf = 2e9;
void solve() {
    int x, y;
    std::cin >> x >> y;
    std::string s, t = "Impossible\n";
    std::cin >> s;
    int a = 0, b = 0;
    std::vector<int> w(4);
    for (auto c : s) {
        if (c == 'L') w[0] ++;
        if (c == 'R') w[1] ++;
        if (c == 'U') w[2] ++;
        if (c == 'D') w[3] ++;
    }
    b = (w[2] - w[3]), a = (w[1] - w[0]);
    if (x == 0 && y == 0) {
        std::cout << t;
        return ;
    }
    if (w[0] == 0 && w[1] == 0) {
        if (y >= std::min(0, b) && y <= std::max(0, b)) {
            std::cout << t;
        } else {
            if (y > 0) {
                for (int i = 0; i < w[3]; i ++) {
                    std::cout << 'D';
                }
                for (int i = 0; i < w[2]; i ++) {
                    std::cout << 'U';
                }
                std::cout << '\n';
            } else {
                for (int i = 0; i < w[2]; i ++) {
                    std::cout << 'U';
                }
                for (int i = 0; i < w[3]; i ++) {
                    std::cout << 'D';
                }
                std::cout << '\n';
            }
        }
        return ;
    } else if (w[2] == 0 && w[3] == 0) {
        if (x >= std::min(0, a) && x <= std::max(0, a)) {
            std::cout << t;
        } else {
            if (x > 0) {
                for (int i = 0; i < w[0]; i ++) {
                    std::cout << 'L';
                }
                for (int i = 0; i < w[1]; i ++) {
                    std::cout << 'R';
                }
                std::cout << '\n';
            } else {
                for (int i = 0; i < w[1]; i ++) {
                    std::cout << 'R';
                }
                for (int i = 0; i < w[0]; i ++) {
                    std::cout << 'L';
                }
                std::cout << '\n';
            }
        }
        return ;
    }

    if (x == a && y == b) {
        std::cout << t;
        return ;
    }
    if (x == a || y == 0) {
        for (int i = 0; i < w[2]; i ++) {
            std::cout << 'U';
        }
        for (int i = 0; i < w[3]; i ++) {
            std::cout << 'D';
        }
        for (int i = 0; i < w[1]; i ++) {
            std::cout << 'R';
        }
        for (int i = 0; i < w[0]; i ++) {
            std::cout << 'L';
        }
        std::cout << '\n';
    } else {
        for (int i = 0; i < w[1]; i ++) {
            std::cout << 'R';
        }
        for (int i = 0; i < w[0]; i ++) {
            std::cout << 'L';
        }
        for (int i = 0; i < w[2]; i ++) {
            std::cout << 'U';
        }
        for (int i = 0; i < w[3]; i ++) {
            std::cout << 'D';
        }
        std::cout << '\n';
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t = 1;
    std::cin >> t;
    while (t --) {
        solve();
    }
    return 0;
}
/*
5
1 1
RURULLD
0 5
UUU
0 3
UUU
0 2
UUU
0 0
UUU
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3468kb

input:

5
1 1
RURULLD
0 5
UUU
0 3
UUU
0 2
UUU
0 0
UUU

output:

RRLLUUD
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3824kb

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:

UUDDRR
UUR
Impossible
Impossible
Impossible
RRUUUUUUD
RRRRLDD
Impossible
Impossible
RRLLLLDD
RRLLUDDD
Impossible
UUDDDDRLL
LL
Impossible
UUUDRRL
Impossible
Impossible
Impossible
RRRLLLLLDD
Impossible
RL
Impossible
Impossible
Impossible
Impossible
Impossible
RRRRRLLLUU
LLLUD
Impossible
UUUDDDL
UUDDRR...

result:

wrong answer case 8, participant does not find an answer but the jury does