QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485176#6699. Wandering RobotInk_baiWA 35ms6316kbC++141.9kb2024-07-20 14:42:532024-07-20 14:42:53

Judging History

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

  • [2024-07-20 14:42:53]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:6316kb
  • [2024-07-20 14:42:53]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
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;
}

signed 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: 100
Accepted
time: 0ms
memory: 3540kb

input:

2
3 3
RUL
1 1000000000
D

output:

4
1000000000

result:

ok 2 number(s): "4 1000000000"

Test #2:

score: -100
Wrong Answer
time: 35ms
memory: 6316kb

input:

10307
33 374631889
RUDUUDLDDUULULDRDDRRRRDDDLRURULDL
9 40711970
UUDLRDRDD
3 111498848
LRL
14 804199874
LRRLLRULRUURUU
44 936610223
ULDRUULRRDLRRLRLRLRDUDDUDDUUDDLRUUDRUURLULUD
15 669124042
RUULRLDDULUDRDR
47 500758328
LRULULLLLUDURLRRDLDDLUUDURUDDLLLLDRLULURDULRDLU
18 581526184
DLLUDUUULUDULULRLR
47...

output:

1873159447
122135910
111498848
4825199244
3746440893
669124044
5508341608
4652209473
5606278385
8301130033
3707957881
2821884978
463006533
1581485530
881213211
236693627
816980016
4406947601
1057578188
1455154265
4107693543
5705944723
3424946932
1154164548
4496114815
3733695266
6323077602
2262619671...

result:

wrong answer 725th numbers differ - expected: '716819386', found: '716819384'