diff --git a/P11375.cpp b/P11375.cpp new file mode 100644 index 0000000..9fdac81 --- /dev/null +++ b/P11375.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +#define int long long +int n, s, t; +int inf = 1e12; +string str; +signed main() +{ + cin >> n >> s; + cin >> str; + for (auto i : str) + { + if (i == 'U') + { + if (s == 1) + continue; + if (t) + { + t--; + continue; + } + s /= 2; + } + if (i == 'L') + { + if (2 * s > inf) + t++; + else + s *= 2; + } + else if (i == 'R') + { + if (2 * s + 1 > inf) + t++; + else + s = s * 2 + 1; + } + } + cout << s << endl; + return 0; +} \ No newline at end of file