QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408703#6699. Wandering RobotCharlie983WA 14ms3756kbC++141.1kb2024-05-10 21:37:162024-05-10 21:37:16

Judging History

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

  • [2024-05-10 21:37:16]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3756kb
  • [2024-05-10 21:37:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ll long long
#define endl '\n'
#define pb push_back
const int N = 1e6 + 10,M=210;
const ll inf=0x3f3f3f3f,mod=1e9+7;
int dx[]={0,0,-1,1},dy[]={-1,1,0,0};
void solve()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int x=0,y=0;
    int maxx=0;
    for(int i=0;i<s.size();i++)
    {
        int op;
        if(s[i]=='D')op=0;
        else if(s[i]=='U')op=1;
        else if(s[i]=='L')op=2;
        else if(s[i]=='R')op=3;
        x+=dx[op];
        y+=dy[op];
        maxx=max(maxx,abs(x)+abs(y));
    }
    int fx=(k-1)*x,fy=(k-1)*y;
    maxx=abs(fx)+abs(fy);
    for(int i=0;i<s.size();i++)
    {
        int op;
        if(s[i]=='D')op=0;
        else if(s[i]=='U')op=1;
        else if(s[i]=='L')op=2;
        else if(s[i]=='R')op=3;
        fx+=dx[op];
        fy+=dy[op];
        maxx=max(maxx,abs(fx)+abs(fy));
    }
    cout<<maxx<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T=1;
    cin>>T;
    while(T--)
    {
    solve();
    }
return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 14ms
memory: 3756kb

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: '25018'