-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomated testing.cpp
More file actions
45 lines (41 loc) · 1018 Bytes
/
Automated testing.cpp
File metadata and controls
45 lines (41 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <vector>
#include <string>
#include<bits/stdc++.h>
using namespace std;
int user_logic(int n, int x, const std::string& s) {
// Write your logic here.
// Parameters:
// n (int): Length of the string
// x (int): Initial position
// s (string): String representing the robot's movements
// Returns:
// int: Number of distinct points visited by the robot
unordered_set<int> st;
st.insert(x);
for(int i=0; i<s.length(); i++){
if(s[i]=='R'){
x++;
}else{
x--;
}
st.insert(x);
}
return st.size();
}
int main() {
int T;
std::cin >> T;
std::vector<int> results;
for (int t = 0; t < T; ++t) {
int n, x;
std::string s;
std::cin >> n >> x >> s;
int result = user_logic(n, x, s);
results.push_back(result);
}
for (int result : results) {
std::cout << result << std::endl;
}
return 0;
}