跳到正文

题解

题解:P14736 [ICPC 2021 Seoul R] Find the House

DUCK_inanimated_约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月13日
更新
2025年12月13日
篇幅
约 1 分钟
题目
P14736

版本

  1. v1当前

题解:P14736 [ICPC 2021 Seoul R] Find the House

思路

很板子的一道题。我记得有原的吧。

用一个变量存储当前的位置,然后每次去按照给定的方式去移动,nn 次后即为结果。注意区分 L 与 R。

代码

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
struct Node{
    int d;char ch;
};
map<int,Node>mp;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        int t,te;char cc;cin>>t>>cc>>te;
        mp[t]=Node{te,cc};
    }
    int now;cin>>now;
    for(int i=1;i<=n;i++){
        int dd=mp[now].d;
        char cc=mp[now].ch;
        if(cc=='L')now-=dd;
        else now+=dd;
    }
    cout<<now;
	return 0;
}
原文