打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

1

来自八中答案网
Boss留言 | 贡献2025年1月19日 (日) 11:05的版本
<code class="language-cpp">int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    while (k--)
    {
        int x, y;
        cin >> x >> y;
        string op;
        cin >> op;
        for (int i = 0; i < op.size(); i++)
        {
            int tx = x, ty = y;
            if (op[i] == 'f')
                ty++;
            else if (op[i] == 'b')
                ty--;
            else if (op[i] == 'l')
                tx--;
            else
                tx++;

            if (tx >= 1 and tx <= n and ty >= 1 and ty <= n)
            {
                x = tx, y = ty;
            }
        }
        cout << x << ' ' << y << '\n';
    }
}
</code>