题目大意: 给定一个机器人的行走方式 你需要取走一段区间 但要保证取走这段区间后机器人最终到达的终点位置是不变的 问这段区间最短时是哪一段 解题思路: 易得,如果重复走到了某些已经走过的点,那么肯定就有一段区间可以被删除 但是行走次数最大有2e5,即用数组记录坐标状态的话起码要开4e5*4e5的空间,显然不可能 所以可以用map储存上一次走到某个坐标是第几步 那么每次只要判断当前的坐标是否已经被走过即可,走过的话就尝试更新答案 因为map中未调用过的int值为0 所以让原点的步数设置为1防止混淆…
链接: https://codeforces.com/contest/1272/problem/B 题意: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0,0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as…
874. Walking Robot Simulation https://www.cnblogs.com/grandyang/p/10800993.html 每走一步(不是没走commands里的一个数字)计算到原点的距离,每走一步都可能遇到障碍物,需要将障碍物的坐标进行存储,以判断是否停止行走. 左转90度,右转90度转换成在x.y的坐标变换上来.左转前进一个index,右转前进一个index,对4取余确保不越界 不知道为什么用unordered_set就编译出错. class Soluti…
problem 874. Walking Robot Simulation solution1: 思路:1)如何表示移动的方向以及移动的位置坐标; 2)障碍物坐标如何检查;3)求解的是最大距离; class Solution { public: int robotSim(vector<int>& commands, vector<vector<int>>& obstacles) { unordered_set<string> obs; ])…
C. Yet Another Walking Robot time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0). Its path is des…
题目链接:https://codeforces.com/contest/1154/problem/D 题解: 贪心思路,没有太阳的时候,优先用可充电电池走,万不得已才用普通电池走.有太阳的时候,如果可充电电池能够充一格电,就用普通电池跑(让可充电池充电),否则就用可充电电池走. AC代码: #include<bits/stdc++.h> using namespace std; ; int n,a,b; bool s[maxn]; int main() { cin>>n>&g…
There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0) . Its path is described as a string ss of length nn consisting of characters 'L', 'R', 'U', 'D'. Each of these characters corresponds to some move: 'L' (l…
题目链接:http://codeforces.com/problemset/problem/752/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He…
A robot on an infinite grid starts at point (0, 0) and faces north.  The robot can receive one of three possible types of commands: -2: turn left 90 degrees -1: turn right 90 degrees 1 <= x <= 9: move forward x units Some of the grid squares are obs…
294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴力模拟. 数组开不下保存边缘块有没有被访问,可以用map. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,…