QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#485169#6699. Wandering RobotInk_baiWA 29ms4796kbC++141.8kb2024-07-20 14:38:212024-07-20 14:38:22

Judging History

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

  • [2024-07-20 14:38:22]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:4796kb
  • [2024-07-20 14:38:21]
  • 提交

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 * (b-1) + max << endl;
    }
}

詳細信息

Test #1:

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

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: 29ms
memory: 4796kb

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
530231948
-548526403
669124044
1213374312
357242177
1311311089
-288804559
-587009415
-1473082318
463006533
1581485530
881213211
236693627
816980016
111980305
1057578188
1455154265
-187273753
1410977427
-870020364
1154164548
201147519
-561272030
2028110306
-2032347625
1...

result:

wrong answer 4th numbers differ - expected: '4825199244', found: '530231948'