QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706388 | #6699. Wandering Robot | futarian# | WA | 0ms | 3928kb | C++14 | 915b | 2024-11-03 11:00:45 | 2024-11-03 11:00:50 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
const int Len = 2e5 + 5;
#define ll long long
int n,m;
char s[Len];
inline ll Iabs(ll x){if(x < 0) x = -x;return x;}
signed main()
{
int T;scanf("%d",&T);
while(T --)
{
scanf("%d %d",&n,&m);
scanf("%s",s + 1);
int mx = 0 , rt = 0;
ll x = 0 , y = 0 , as = 0;
for(int i = 1 ; i <= n ; i ++)
{
if(s[i] == 'U') y ++;
else if(s[i] == 'D') y --;
else if(s[i] == 'L') x --;
else x ++;
}
ll ox = x , oy = y;
for(int k = 1 ; k <= 20 ; k ++)
{
x = 1ll * (m - k) * ox , y = 1ll * (m - k) * oy;
as = max(as , Iabs(x) + Iabs(y));
for(int p = 1 ; p <= k ; p ++)
for(int i = 1 ; i <= n ; i ++)
{
if(s[i] == 'U') y ++;
else if(s[i] == 'D') y --;
else if(s[i] == 'L') x --;
else x ++;
as = max(as , Iabs(x) + Iabs(y));
}
}
printf("%lld\n",as);
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3928kb
input:
2 3 3 RUL 1 1000000000 D
output:
18 1000000000
result:
wrong answer 1st numbers differ - expected: '4', found: '18'