QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706389 | #6699. Wandering Robot | futarian# | WA | 445ms | 3976kb | C++14 | 925b | 2024-11-03 11:01:23 | 2024-11-03 11:01:24 |
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 <= m ; 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
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: 445ms
memory: 3976kb
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 10306th numbers differ - expected: '49990', found: '25056'