1 条题解
-
0
找到移动后每个点的位置,然后判断是否有点重复。
判断重复 种方法:(代码采用1)
- 桶数组:由于数据范围太大,所以数组实现略麻烦,使用 较为方便。
- 排序:对移动后的点排序,遍历坐标找相邻的点是否相等。
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; #define x first #define y second const int N = 2e5 + 10, M = 60; PII a[N]; void solve() { int n; cin >> n; for(int i = 0; i < n; i ++) { cin >> a[i].x >> a[i].y; } string s; cin >> s; map<PII,int> m; for(int i = 0; i < s.size(); i ++) { int x = a[i].x, y = a[i].y; if(s[i] == 'L') x --; else x ++; if(m.count({x, y})) { cout << "Yes" << endl; return; } m[{x, y}] = 1; } cout << "No" << endl; } int main() { int t = 1; // cin >> t; while(t --) solve(); }
- 1
信息
- ID
- 438
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 6
- 已通过
- 3
- 上传者