QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506631#6422. Evil Coordinate122WA 0ms3544kbC++141.4kb2024-08-05 20:19:252024-08-05 20:19:27

Judging History

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

  • [2024-08-05 20:19:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-08-05 20:19:25]
  • 提交

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