QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#388987 | #6699. Wandering Robot | Mayuri | AC ✓ | 12ms | 3724kb | C++14 | 1.7kb | 2024-04-13 22:52:01 | 2024-04-13 22:52:02 |
Judging History
answer
//#define _CRT_SECURE_NO_WARNINGS
//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//typedef long double ld;
//#define endl '\n'
//const ll maxn = 2e5 + 5;
//ll T;
//ll n, m, k;
//ll u[maxn], v[maxn];
//
//int main()//D
//{
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// cin >> T;
// while (T--) {
// cin >> k;
// string s; cin >> s;
// cin >> n >> m;
// for (ll i = 1; i <= m; i++) {
// ll u, v; cin >> u >> v;
// }
// ll d = m - n + 2;
// d--;
// ll t = d % k;
// if (s[t] == '1') cout << 2 << endl;
// else cout << 1 << endl;
// }
//}
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl '\n'
const ll maxn = 2e5 + 5;
ll T;
ll n, m, k;
ll u[maxn], v[maxn];
ll dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
ll f(char ch) {
if (ch == 'U')return 0;
if (ch == 'R')return 1;
if (ch == 'D')return 2;
if (ch == 'L')return 3;
}
int main()//C
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--) {
cin >> n >> k;
string s; cin >> s;
ll bx = 0, by = 0;
ll mx = 0, my = 0;
ll mmax = 0;
for (ll i = 0; i < s.size(); i++) {
ll t = f(s[i]);
bx += dx[t];
by += dy[t];
if (abs(bx) + abs(by) > abs(mx) + abs(my)) {
mx = bx;
my = by;
}
}
bx = bx * (k - 1);
by = by * (k - 1);
ll tx = 0, ty = 0;
for (ll i = 0; i < s.size(); i++) {
ll t = f(s[i]);
bx += dx[t];
by += dy[t];
if (abs(bx) + abs(by) > abs(tx) + abs(ty)) {
tx = bx;
ty = by;
}
}
cout << max(abs(tx) + abs(ty), abs(mx) + abs(my)) << endl;
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3556kb
input:
2 3 3 RUL 1 1000000000 D
output:
4 1000000000
result:
ok 2 number(s): "4 1000000000"
Test #2:
score: 0
Accepted
time: 12ms
memory: 3724kb
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