QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#469621#6699. Wandering Robotmufeng12#WA 23ms3788kbC++142.1kb2024-07-09 21:07:162024-07-09 21:07:16

Judging History

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

  • [2024-07-09 21:07:16]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3788kb
  • [2024-07-09 21:07:16]
  • 提交

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]);
    }
    x*=(k-1),y*=(k-1);
    x=abs(x);y=abs(y);
    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(X)+abs(Y)+x+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: 3788kb

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: 23ms
memory: 3632kb

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
2821884982
463006533
1581485530
881213211
236693627
816980016
4406947601
1057578188
1455154265
4107693543
5705944723
3424946932
1154164548
4496114815
3733695266
6323077602
2262619671...

result:

wrong answer 12th numbers differ - expected: '2821884978', found: '2821884982'