QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#682347#6422. Evil CoordinateBlizzardCompile Error//C++145.1kb2024-10-27 15:06:182024-10-27 15:06:20

Judging History

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

  • [2024-10-27 15:06:20]
  • 评测
  • [2024-10-27 15:06:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

//--------------------------------
// #define int long long
#define LL long long
// #define lc p << 1
// #define rc p << 1 | 1
#define lowbit(x) x & (-x)
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
// #pragma GCC optimize(2)
#define Blizzard ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"

//-----------------------------------------
int x, y;
int cnt[4];
void solve()
{

    cin >> x >> y;
    int nowx = 0, nowy = 0;
    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
    string s;
    cin >> s;
    int visstep = -1;
    int finalx = 0, finaly = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'U')
        {
            cnt[0]++;
            nowy++;
        }
        if (s[i] == 'D')
        {
            cnt[1]++;
            nowy--;
        }
        if (s[i] == 'L')
        {
            cnt[2]++;
            nowx--;
        }
        if (s[i] == 'R')
        {
            cnt[3]++;
            nowx++;
        }

        if (nowx == x && nowy == y)
        {
            visstep = i + 1;
        }
    }

    finalx = nowx, finaly = nowy;
    string ans;

    if ((finalx == x && finaly == y) || (x == 0 && y == 0))
    {
        cout << "Impossible\n";
        return;
    }

    if (visstep == -1)
    {
        cout << s << '\n';
        return;
    }

    if ((cnt[1] == 0 && cnt[0] == 0) || (cnt[2] == 0 && cnt[3] == 0))
    {
        if ((cnt[1] == 0 && cnt[0] == 0))
        {
            if (x < 0)
            {
                if (cnt[3] - cnt[2] <= x)
                {

                    cout << "Impossible\n";
                    return;
                }
                while (cnt[3])
                {
                    ans.push_back(3);
                    cnt[3]--;
                }
                while (cnt[2])
                {
                    cnt[2]--;
                    ans.push_back(2);
                }
                for (int i = 0; i < ans.size(); i++)
                {
                    if (ans[i] == 0)
                        cout << 'U';
                    if (ans[i] == 1)
                        cout << 'D';
                    if (ans[i] == 2)
                        cout << 'L';
                    if (ans[i] == 3)
                        cout << 'R';
                }
                cout << '\n';
                return;
            }
            else
            {
                if (-1 * cnt[2] + cnt[3] >= x)
                {
                    cout << "Impossible\n";
                    return;
                }

                while (cnt[2])
                {
                    cnt[2]--;
                    ans.push_back(2);
                }
                while (cnt[3])
                {
                    ans.push_back(3);
                    cnt[3]--;
                }
                for (int i = 0; i < ans.size(); i++)
                {
                    if (ans[i] == 0)
                        cout << 'U';
                    if (ans[i] == 1)
                        cout << 'D';
                    if (ans[i] == 2)
                        cout << 'L';
                    if (ans[i] == 3)
                        cout << 'R';
                }
                cout << '\n';
                return;
            }
        }
        else if ((cnt[2] == 0 && cnt[3] == 0))
        {
            if (y > 0)
            {
                if (-1 * cnt[1] + cnt[0] >= y)
                {
                    cout << "Impossible\n";
                    return;
                }
                while (cnt[1])
                {
                    cnt[1]--;
                    ans.push_back(1);
                }
                while (cnt[0])
                {
                    ans.push_back(0);
                    cnt[0]--;
                }
            }
            else
            {
                if (cnt[0] - cnt[1] <= y)
                {
                    cout << "Impossible\n";
                    return;
                }
                while (cnt[0])
                {
                    cnt[0]--;
                    ans.push_back(0);
                }
                while (cnt[1])
                {
                    ans.push_back(1);
                    cnt[1]--;
                }
            }
            for (int i = 0; i < ans.size(); i++)
            {
                if (ans[i] == 0)
                    cout << 'U';
                if (ans[i] == 1)
                    cout << 'D';
                if (ans[i] == 2)
                    cout << 'L';
                if (ans[i] == 3)
                    cout << 'R';
            }
            cout << '\n';
            return;
        }
        cout << "Impossible\n";
        return;
    }
    nowx = nowy = 0;
    if (((x == 1 || x == -1) && (y == 0)) || ((y == 1 || y == -1) && (x == 0)))
    {
        if ((x == 1 || x == -1) && (y == 0))
        {

            if (cnt[0])
 

Details

answer.code: In function ‘void solve()’:
answer.code:202:24: error: expected statement at end of input
  202 |             if (cnt[0])
      |                        ^
answer.code:202:24: error: expected ‘}’ at end of input
answer.code:200:9: note: to match this ‘{’
  200 |         {
      |         ^
answer.code:202:24: error: expected ‘}’ at end of input
  202 |             if (cnt[0])
      |                        ^
answer.code:198:5: note: to match this ‘{’
  198 |     {
      |     ^
answer.code:202:24: error: expected ‘}’ at end of input
  202 |             if (cnt[0])
      |                        ^
answer.code:19:1: note: to match this ‘{’
   19 | {
      | ^