QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613365#6699. Wandering Robotzqx#AC ✓15ms4020kbC++231.1kb2024-10-05 13:57:482024-10-05 13:59:58

Judging History

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

  • [2024-10-05 13:59:58]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:4020kb
  • [2024-10-05 13:57:48]
  • 提交

answer

#include<bits/stdc++.h>
#define AC return 0;
#define int long long 
#define pii pair<int,int>
#define all(tar) tar.begian(),tar.end()
const int maxx=2e5+5;
const int mod=998244353; 
using namespace std;

void Solve()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s = ' ' + s;
    int x, y;
    x = y = 0;
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        if (s[i] == 'U') y++;
        if (s[i] == 'D') y--;
        if (s[i] == 'L') x--;
        if (s[i] == 'R') x++;
        res = max(res, abs(x) + abs(y));
    }
    
    x = (k - 1) * x;
    y = (k - 1) * y;
    res = max(res, abs(x) + abs(y)); 

    for (int i = 1; i <= n; i++)
    {
        if (s[i] == 'U') y++;
        if (s[i] == 'D') y--;
        if (s[i] == 'L') x--;
        if (s[i] == 'R') x++;
        res = max(res, abs(x) + abs(y));
    }

    cout << res << "\n";
}

signed main(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   


   int T;
   cin >> T;
   while (T--)
   {
    Solve();
   }
   
   AC
}       

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3 3
RUL
1 1000000000
D

output:

4
1000000000

result:

ok 2 number(s): "4 1000000000"

Test #2:

score: 0
Accepted
time: 15ms
memory: 4020kb

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:

ok 10307 numbers