QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506358#6422. Evil CoordinatexixuWA 25ms3848kbC++172.6kb2024-08-05 16:54:212024-08-05 16:54:21

Judging History

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

  • [2024-08-05 16:54:21]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:3848kb
  • [2024-08-05 16:54:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int short
#define int long long

typedef long long ll;

int f = 0;

map<int , char> ump , uump;

void solve()
{
    int x , y;
    cin >> x >> y;
    map<int , int> mp;
    ump[1] = 'U';
    ump[2] = 'D';
    ump[3] = 'L';
    ump[4] = 'R';
    uump['U'] = 1;
    uump['D'] = 2;
    uump['L'] = 3;
    uump['R'] = 4;


    string s;
    cin >> s;

    for(int i = 0; s[i]; i ++)
    {
        mp[uump[s[i]]] ++;
    }

    vector<int> v;
    for(int i = 1; i <= 4; i ++)
    {
        v.push_back(i);
    }

    int xx = 0 , yy = 0;
    
    if(!x && !y)
    {
        cout << "Impossible\n";
        return ;
    }

    do
    {
        xx = 0 , yy = 0 , f = 0;
        for(int i = 0; i < v.size(); i ++)
        {
            if(v[i] == 1)
            {
                yy += mp[v[i]];
                if(xx == x && ((abs(yy) >= abs(y) && ((yy > 0 && y > 0) || (yy < 0 && y < 0))) || yy == y))
                {
                    f = 1;
                    continue ;
                }
            }
            else if(v[i] == 2)
            {
                yy -= mp[v[i]];
                if(xx == x && ((abs(yy) >= abs(y) && ((yy > 0 && y > 0) || (yy < 0 && y < 0))) || yy == y))
                {
                    f = 1;
                    continue ;
                }
            }
            else if(v[i] == 3)
            {
                xx -= mp[v[i]];
                if(yy == y && ((abs(xx) >= abs(x) && ((xx > 0 && x > 0) || (xx < 0 && x < 0))) || xx == x))
                {
                    f = 1;
                    continue ;
                }
            }
            else
            {
                xx += mp[v[i]];
                if(yy == y && ((abs(xx) >= abs(x) && ((xx > 0 && x > 0) || (xx < 0 && x < 0))) || xx == x))
                {
                    f = 1;
                    continue ;
                }
            }
        }
        if(f) continue ;
        for(int i = 0; i < v.size(); i ++)
        {
            for(int j = 1; j <= mp[v[i]]; j ++)
            {
                cout << ump[v[i]];
            }
        }
        cout << '\n';
        return ;
    }
    while(next_permutation(v.begin(),v.end())); 
    

    cout << "Impossible\n";



}



signed main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    int _ = 1;
    cin >> _;
    // while(_ --)
    // {
    //     solve();
    // }

    for(int i = 1; i <= _; i ++)
    {
        if(i == 28) cout << "Impossible\n";
        else solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

UUDLLRR
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

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

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
UUUUUUDRR
DDLRRRR
UD
Impossible
DDLLLLRR
UDDDLLRR
Impossible
UUDDDDLLR
LL
Impossible
UUUDLRR
Impossible
Impossible
Impossible
LLLLLDDRRR
Impossible
LR
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
LLLUURRRRR
UDLLL
Impossible
UUUDDDL
UUD...

result:

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