QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469624#6699. Wandering Robotmufeng12#WA 31ms3704kbC++232.0kb2024-07-09 21:12:212024-07-09 21:12:21

Judging History

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

  • [2024-07-09 21:12:21]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3704kb
  • [2024-07-09 21:12:21]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(x) (x).begin(),(x).end()
#define maxint INT32_MAX
#define minint INT32_MIN
#define maxll INT64_MAX
#define minll INT64_MIN
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
#pragma GCC optimize(2)
void write(int x);
char *p1,*p2,buf[100000];
int read();
ll ksm(ll a,ll b,ll mod);
int js(int a,int b,int c){
    int ans1,ans;
    ans1=a+b>a*b?a+b:a*b;
    ans=ans1+c>ans1*c?ans1+c:ans1*c;
    return ans;
}
void yd(ll &a,ll &b,char c){
    if(c=='R')a++;
    else if(c=='L')a--;
    else if(c=='D')b++;
    else b--;
}
void solve(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll x,y;
    x=y=0;
    for(int i=0;i<n;i++){
        yd(x,y,s[i]);
    }
    ll X=0,Y=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        yd(X,Y,s[i]);
        //ans=max(ans,abs(X)+abs(Y));
        ans=max(ans,abs((k-1)*x+X)+abs((k-1)*y+Y));
    }
    cout<<ans<<endl;
}


int main() {
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}



void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}
int read()
{
    int x=0,f=1;
    char ch=nc();
    while(ch<48||ch>57)
    {
        if(ch=='-')
            f=-1;
        ch=nc();
    }
    while(ch>=48&&ch<=57)
        x=x*10+ch-48,ch=nc();
   	return x*f;
}
ll ksm(ll a,ll b,ll mod){
    ll ans=1;
    a%=mod;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 31ms
memory: 3704kb

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'