QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706238 | #6699. Wandering Robot | futarian# | WA | 32ms | 3936kb | C++14 | 590b | 2024-11-03 09:35:41 | 2024-11-03 09:35:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//string day[5]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int main()
{
int t,n,k;
string step;
cin>>t;
while(t--)
{
cin>>n>>k;
cin>>step;
long long x=0,y=0;
long long maxdisx=0,maxdisy=0,ans;
for(int i=0;i<n;i++)
{
if(step[i]=='L') x--;
else if(step[i]=='R') x++;
else if(step[i]=='U') y--;
else if(step[i]=='D') y++;
if((abs(x)+abs(y))>=(abs(maxdisx)+abs(maxdisy))) maxdisy=y,maxdisx=x;
}
ans=abs(x*(k-1)+maxdisx)+abs(y*(k-1)+maxdisy);
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3564kb
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: 32ms
memory: 3936kb
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 669124042 5508341608 4652209473 5606278385 8301130033 3707957881 2821884976 463006533 1581485530 881213211 236693627 816980016 4406947601 1057578188 1455154265 4107693543 5705944723 3424946932 1154164548 4496114815 3733695266 6323077602 2262619671...
result:
wrong answer 6th numbers differ - expected: '669124044', found: '669124042'