QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#472928 | #6699. Wandering Robot | YangHyyy | WA | 28ms | 3808kb | C++23 | 557b | 2024-07-11 20:25:09 | 2024-07-11 20:25:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int p=1e9+7;
void solve()
{
int n,k;
int ans=0;
cin>>n>>k;
string s;
cin>>s;
map<char,int> mp;
for(int i=0;i<s.size();i++)
{
mp[s[i]]++;
}
if((mp['L']==0&&mp['D']==0)||(mp['R']==0&&mp['U']==0))
{
ans=k;
cout<<ans<<endl;
return;
}
int jia=mp['U']+mp['R'],jian=mp['L']+mp['D'];
int dy=max(jia,jian);
ans=dy+(abs(jia-jian))*(k-1);
cout<<ans<<endl;
return ;
}
signed main()
{
int t;
cin>>t;
while(t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 28ms
memory: 3696kb
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:
374631905 40711974 111498849 4825199248 3746440912 669124049 3505308316 9 800896935 8301130048 1853978945 940628340 463006533 1581485536 881213211 236693627 408490021 1101736913 4 1455154281 4107693562 5705944740 3424946944 1154164554 1498704962 3733695282 4742308211 969694166 1212040575 1036828622 ...
result:
wrong answer 1st numbers differ - expected: '1873159447', found: '374631905'