QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#485176 | #6699. Wandering Robot | Ink_bai | WA | 35ms | 6316kb | C++14 | 1.9kb | 2024-07-20 14:42:53 | 2024-07-20 14:42:53 |
Judging History
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;
}
}
詳細信息
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'