QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#143403#6699. Wandering Robotqzez#AC ✓12ms4792kbC++141.0kb2023-08-21 10:58:322023-08-21 10:58:41

Judging History

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

  • [2023-08-21 10:58:41]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:4792kb
  • [2023-08-21 10:58:32]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=N*4+5,K=31650,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,k,X[N],Y[N];
char s[N];
void Solve(){
	int i,j;scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	for(i=1;i<=n;i++) {
		X[i]=X[i-1];Y[i]=Y[i-1];
		if(s[i]=='L') X[i]--;
		if(s[i]=='R') X[i]++;
		if(s[i]=='U') Y[i]--;
		if(s[i]=='D') Y[i]++;
	}
	ll ans=0;
	for(i=1;i<=n;i++) {
		ans=max(ans,1ll*abs(X[i])+1ll*abs(Y[i]));
		ans=max(ans,abs(X[i]+1ll*(k-1)*X[n])+abs(Y[i]+1ll*(k-1)*Y[n]));
	}
	printf("%lld\n",ans);
}
int main(){
	int t;scanf("%d",&t);while(t--) Solve();
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

2
3 3
RUL
1 1000000000
D

output:

4
1000000000

result:

ok 2 number(s): "4 1000000000"

Test #2:

score: 0
Accepted
time: 12ms
memory: 4792kb

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:

ok 10307 numbers