1 solutions
-
0
签到题,不解释。只要判断越界的边界情况即可。
#include <stdio.h> #include <algorithm> int n, k; int x, y; char s[114]; void solve() { scanf("%d%d%s", &x, &y, s); for (int i = 0; s[i]; ++i) switch (s[i]) { case 'f': y = std::min(y + 1, n); break; case 'b': y = std::max(y - 1, 1); break; case 'l': x = std::max(x - 1, 1); break; case 'r': x = std::min(x + 1, n); break; } printf("%d %d\n", x, y); } int main() { scanf("%d%d", &n, &k); while (k--) solve(); }
- 1
Information
- ID
- 40
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 1
- Tags
- # Submissions
- 15
- Accepted
- 12
- Uploaded By