QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152592#6699. Wandering RobotqzhwlzyWA 8ms3728kbC++14612b2023-08-28 13:22:372023-08-28 13:22:37

Judging History

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

  • [2023-08-28 13:22:37]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3728kb
  • [2023-08-28 13:22:37]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define maxn 100005
#define ll long long
using namespace std;
int T,n,k,u,d,l,r; ll x=0,y=0,ans=0; char a[maxn]; ll aabs(ll x){return x<0?-x:x;}
int main(){
	scanf("%d",&T); while(T--){
		scanf("%d%d\n%s",&n,&k,a+1); u=d=l=r=0;
		for(int i=1;i<=n;i++) if(a[i]=='U') u++; else if(a[i]=='D') d++; else if(a[i]=='L') l++; else r++;
		x=(r-l)*(k-1); y=(u-d)*(k-1); ans=aabs(x)+aabs(y); for(int i=1;i<=n;i++){
			if(a[i]=='U') y++; else if(a[i]=='D') y--; else if(a[i]=='L') x--; else x++; 
			ans=max(aabs(x)+aabs(y),ans);
		} printf("%lld\n",ans);
	} return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

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: 8ms
memory: 3728kb

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
1078167805
3746440893
669124044
1213374312
3937725129
2983656215
3609256582
2440988358
2821884978
463006533
1581485530
881213211
236693627
816980016
3193230400
1057578188
1455154265
2925736123
2883989880
2924988528
1154164548
2796262364
2858930663
2028110306
2262619671...

result:

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