QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485165#6699. Wandering RobotInk_baiWA 0ms3564kbC++141.9kb2024-07-20 14:36:122024-07-20 14:36:12

Judging History

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

  • [2024-07-20 14:36:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-07-20 14:36:12]
  • 提交

answer

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

int ppox(int x, int y)
{
    if(x >= 0 && y >= 0) return x + y;
    else if(x >= 0 && y < 0) return x - y;
    else if(x < 0 && y >= 0) return y - x;
    else return 0 - x - y;
}

int main()
{
    int n;
    cin >> n;
    while(n--)
    {
        int posx = 0, posy = 0;
        int a, b;
        cin >> a >> b;
        string s;
        cin >> s;
        vector<int> vx, vy;
        for(int i=0; i<s.size(); i++)
        {
            if(s[i] == 'U') posy++;
            else if(s[i] == 'D') posy--;
            else if(s[i] == 'L') posx--;
            else if(s[i] == 'R') posx++;
            vx.push_back(posx);
            vy.push_back(posy);
        }
        int max = 0;
        if(posx >= 0 && posy >= 0)
        {
            for(int i=0; i<s.size(); i++)
            {
                if(vx[i] >= 0 && vy[i] >= 0)
                    if(ppox(vx[i], vy[i]) > max) max = ppox(vx[i], vy[i]);
            }
        }
        if(posx >= 0 && posy <= 0)
        {
            for(int i=0; i<s.size(); i++)
            {
                if(vx[i] >= 0 && vy[i] <= 0)
                    if(ppox(vx[i], vy[i]) > max) max = ppox(vx[i], vy[i]);
            }
        }
        if(posx <= 0 && posy >= 0)
        {
            for(int i=0; i<s.size(); i++)
            {
                if(vx[i] <= 0 && vy[i] >= 0)
                    if(ppox(vx[i], vy[i]) > max) max = ppox(vx[i], vy[i]);
            }
        }
        if(posx <= 0 && posy <= 0)
        {
            for(int i=0; i<s.size(); i++)
            {
                if(vx[i] <= 0 && vy[i] <= 0)
                    if(ppox(vx[i], vy[i]) > max) max = ppox(vx[i], vy[i]);
            }
        }
        int temp = abs(posx) + abs(posy);
         cout << temp << " " << max << endl;
        cout << temp * (b-1) + max << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3564kb

input:

2
3 3
RUL
1 1000000000
D

output:

1 2
4
1 1
1000000000

result:

wrong answer 1st numbers differ - expected: '4', found: '1'