QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#236060#6699. Wandering Robotstcmuyi#AC ✓6ms4696kbC++201.0kb2023-11-03 15:58:502023-11-03 15:58:50

Judging History

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

  • [2023-11-03 15:58:50]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:4696kb
  • [2023-11-03 15:58:50]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define i64 long long
#define endl '\n'
#define lb(x) ((x) & (-x))
using namespace std;
const i64 mod = 1e15+7;
const int maxn = 1e3+10;
int dir[4][2] = {-1,0,1,0,0,-1,0,1};
int ck(char c)
{
    if(c == 'U') return 3;
    if(c == 'D') return 2;
    if(c == 'L') return 0;
    return 1;
}
signed main()
{
    IOS;
    int t; cin >> t;
    while(t--)
    {
        i64 n,k; cin >> n >> k;
        i64 x = 0,y = 0;
        string s; cin >> s;
        s = " "+s;
        vector<pair<int,int>> v(n+1);
        i64 mx = 0;
        for(int i = 1; i <= n; ++i)
        {
            int z = ck(s[i]);
            x += dir[z][0];
            y += dir[z][1];
            v[i] = {x,y};
            mx = max(mx,abs(x) + abs(y));
        }
        x *= (k-1),y *= (k-1);
        for(int i = 1; i <= n; ++i) mx = max(mx,abs(x + v[i].first)+abs(y+v[i].second));
        cout << mx << endl;
    }
    return 0;
}

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

详细

Test #1:

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

input:

2
3 3
RUL
1 1000000000
D

output:

4
1000000000

result:

ok 2 number(s): "4 1000000000"

Test #2:

score: 0
Accepted
time: 6ms
memory: 4696kb

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