QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506266#6422. Evil CoordinateaposCompile Error//C++144.3kb2024-08-05 16:18:292024-08-05 16:18:30

Judging History

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

  • [2024-08-05 16:18:30]
  • 评测
  • [2024-08-05 16:18:29]
  • 提交

answer

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

typedef long long ll;


// const int M = 1e4 + 10 , inf = 0x3f3f3f3f , N = 1e6 + 10;

int f = 0;




void solve()
{
    int x , y;
    cin >> x >> y;

    string s;
    cin >> s;
    map<char , int> mp;
    map<char , int> mmp;
    for(int i = 0; s[i]; i ++)
    {
        if(s[i] == 'U')
        {
            mp['y'] ++;
            mmp['U'] ++;
        }
        else if(s[i] == 'D')
        {
            mp['y'] --;
            mmp['D'] ++;
        }
        else if(s[i] == 'L')
        {
            mp['x'] --;
            mmp['L'] ++;
        }
        else
        {
            mp['x'] ++;
            mmp['R'] ++;
        }
    }

    if((mp['x'] == x && mp['y'] == y) || (!x && !y) || (!mmp['D'] && !mmp['U'] && !y && ((mp['x'] >= x && x >= 0) || (mp['x'] <= x && x <= 0))) || (!mmp['L'] && !mmp['R'] && !x && ((mp['y'] >= y && y > 0) || (mp['y'] < y && y < 0))))
    {
        cout << "Impossible\n";
        return ;
    }

A
    if(y >= 0)
    {
        for(int i = 1; i <= mmp['D']; i ++)
        {
            cout << 'D';
        }
    }
    else
    {
        for(int i = 1; i <= mmp['U']; i ++)
        {
            cout << 'U';
        }
    }

    if(x >= 0)
    {
        for(int i = 1; i <= mmp['L']; i ++)
        {
            cout << 'L';
        }
        if(y >= 0)//UR
        {
            if(mp['y'] != y)
            {
                for(int i = 1; i <= mmp['U']; i ++)
                {
                    cout << 'U';
                }
                for(int i = 1; i <= mmp['R']; i ++)
                {
                    cout << 'R';
                }

            }
            else
            {
                for(int i = 1; i <= mmp['R']; i ++)
                {
                    cout << 'R';
                }
                for(int i = 1; i <= mmp['U']; i ++)
                {
                    cout << 'U';
                }
            }
        }
        else//DR
        {
            if(mp['y'] != y)
            {
                for(int i = 1; i <= mmp['D']; i ++)
                {
                    cout << 'D';
                }
                for(int i = 1; i <= mmp['R']; i ++)
                {
                    cout << 'R';
                }
            }
            else
            {
                for(int i = 1; i <= mmp['R']; i ++)
                {
                    cout << 'R';
                }
                for(int i = 1; i <= mmp['D']; i ++)
                {
                    cout << 'D';
                }
            }
        }
    }
    else
    {
        for(int i = 1; i <= mmp['R']; i ++)
        {
            cout << 'R';
        }
        if(y >= 0)//UL
        {
            if(mp['y'] != y)
            {
                for(int i = 1; i <= mmp['U']; i ++)
                {
                    cout << 'U';
                }
                for(int i = 1; i <= mmp['L']; i ++)
                {
                    cout << 'L';
                }
            }
            else
            {
                for(int i = 1; i <= mmp['L']; i ++)
                {
                    cout << 'L';
                }
                for(int i = 1; i <= mmp['U']; i ++)
                {
                    cout << 'U';
                }
            }
        }
        else//DL
        {
            if(mp['y'] != y)
            {
                for(int i = 1; i <= mmp['D']; i ++)
                {
                    cout << 'D';
                }
                for(int i = 1; i <= mmp['L']; i ++)
                {
                    cout << 'L';
                }
            }
            else
            {
                for(int i = 1; i <= mmp['L']; i ++)
                {
                    cout << 'L';
                }
                for(int i = 1; i <= mmp['D']; i ++)
                {
                    cout << 'D';
                }
            }
        }
    }
    cout << '\n';





}



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

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

    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:55:1: error: ‘A’ was not declared in this scope
   55 | A
      | ^
answer.code:63:5: error: ‘else’ without a previous ‘if’
   63 |     else
      |     ^~~~