QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469583#6699. Wandering Robotzzisjtu#AC ✓14ms3856kbC++231.1kb2024-07-09 20:23:392024-07-09 20:23:40

Judging History

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

  • [2024-07-09 20:23:40]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:3856kb
  • [2024-07-09 20:23:39]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
#define lowbit(i) ((i)&(-i))
#define pii pair<int,int>
#define endl '\n'
#define mk(x,y) make_pair(x,y)
#define popcount(x) __builtin_popcount(x)
const double pi=3.14159265358979323846;
const double eps=1e-9;
const int inf=1e9;
const long long INF=4e18;
const int mod=1e9+7;
using namespace std;
const int N=1e5+10;
void solve()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int x=0,y=0;
    for(int i=0;i<n;i++){
        if(s[i]=='U')y+=1;
        else if(s[i]=='D')y-=1;
        else if(s[i]=='L')x-=1;
        else if(s[i]=='R')x+=1;
    }
    int xx=0,yy=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='U')yy+=1;
        else if(s[i]=='D')yy-=1;
        else if(s[i]=='L')xx-=1;
        else if(s[i]=='R')xx+=1;
        ans = max({
            ans,abs(xx)+abs(yy),abs((k-1)*x+xx)+abs((k-1)*y+yy)
        });
    }
    cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3856kb

input:

2
3 3
RUL
1 1000000000
D

output:

4
1000000000

result:

ok 2 number(s): "4 1000000000"

Test #2:

score: 0
Accepted
time: 14ms
memory: 3816kb

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