QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#469617 | #6699. Wandering Robot | mufeng12# | WA | 16ms | 3844kb | C++14 | 2.0kb | 2024-07-09 21:01:06 | 2024-07-09 21:01:06 |
Judging History
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);
ll ans=0;
for(int i=0;i<n;i++){
yd(x,y,s[i]);
ans=max(ans,abs(x)+abs(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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 16ms
memory: 3672kb
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'