QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506320#6422. Evil CoordinateGrunrayWA 25ms4056kbC++202.5kb2024-08-05 16:39:512024-08-05 16:39:51

Judging History

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

  • [2024-08-05 16:39:51]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:4056kb
  • [2024-08-05 16:39:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e3 + 5;
int a[N];
int b[N]; int n, m;
int c[N];
int coun[N];
double l[N], r[N];
void solve()
{

    int x, y;
    cin >> x >> y;
    string s;
    cin >> s;
    memset(a, 0, sizeof(a));
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'U') a[0]++;
        if (s[i] == 'D') a[1]++;
        if (s[i] == 'L') a[2]++;
        if (s[i] == 'R') a[3]++;

    }
    if (((a[0] - a[1]) == y) && ((a[3] - a[2]) == x))
    {
        cout << "Impossible" << endl;
        return;
    }
    else if ((a[2] == 0 && a[3] == 0))
    {
        if (y >= 0 && a[0] - a[1] >= y)
        {
            cout << "Impossible" << endl;
            return;

        }
        if (y <= 0 && a[0] - a[1] <= y)
        {
            cout << "Impossible" << endl;
            return;

        }
    }
    else if ((a[0] == 0 && a[1] == 0))
    {
        if (x >= 0 && a[3] - a[2] >= x)
        {
            cout << "Impossible" << endl;
            return;

        }
        if (x <= 0 && a[3] - a[2] <= x)
        {
            cout << "Impossible" << endl;
            return;

        }
    }

    if (a[0] - a[1] == y)
    {
        if (y == 0)
        {
            cout << "U";
            for (int i = 0; i < a[3]; i++) cout << "R";
            for (int i = 0; i < a[2]; i++) cout << "L";
            for (int i = 0; i < a[0] - 1; i++) cout << "U";
            for (int i = 0; i < a[1]; i++) cout << "D";
        }
        else
        {
            for (int i = 0; i < a[3]; i++) cout << "R";
            for (int i = 0; i < a[2]; i++) cout << "L";
            for (int i = 0; i < a[1]; i++) cout << "D";
            for (int i = 0; i < a[0]; i++) cout << "U";
        }
    }
    else if (a[3] - a[2] == x)
    {
        for (int i = 0; i < a[1]; i++) cout << "D";
        for (int i = 0; i < a[0]; i++) cout << "U";
        for (int i = 0; i < a[3]; i++) cout << "R";
        for (int i = 0; i < a[2]; i++) cout << "L";
    }
    else
    {
        for (int i = 0; i < a[3]; i++) cout << "R";
        for (int i = 0; i < a[2]; i++) cout << "L";
        for (int i = 0; i < a[1]; i++) cout << "D";
        for (int i = 0; i < a[0]; i++) cout << "U";
    }
    cout << endl;

}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

}

详细

Test #1:

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

input:

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

output:

RRLLDUU
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 25ms
memory: 4056kb

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:

URRUDD
RUU
RDUU
Impossible
Impossible
RRDUUUUUU
RRRRLDD
Impossible
Impossible
RRLLLLDD
RRLLDDDU
Impossible
DDDDUURLL
ULL
Impossible
DUUURRL
Impossible
Impossible
Impossible
RRRLLLLLDD
Impossible
URL
Impossible
Impossible
RRRLDDDDUU
LDUU
Impossible
RRRRRLLLUU
LLLDU
Impossible
ULUUDDD
DDUURR
Impossibl...

result:

wrong answer case 3, participant's output goes through forbidden coordinate