CSU 1510 Happy Robot
1510: Happy Robot
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 19 Solved: 7
Description

Input
There will be at most 1000 test cases. Each case contains a command sequence with no more than 1000 characters.
Output
For each test case, print the case number, followed by minimal/maximal possible x (in this order), then the minimal/maximal possible y.
Sample Input
F?F
L??
LFFFRF
Sample Output
Case 1: 1 3 -1 1
Case 2: -1 1 0 2
Case 3: 1 1 3 3
HINT
Source
解题:dp啦,现场居然没做出来。。。笨得还可以。。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = ;
char cmd[maxn];
int dp[][];
const int dir[][] = {,,,-,-,,,};//右 下 左 上
int mymax(int a,int b){
return max(a,b);
}
int mymin(int a,int b){
return min(a,b);
}
int go(int (*op)(int,int),bool flag,int x,int y){
int cur = ;
dp[][] = ;
for(int i = ; i < ; ++i)
if(flag) dp[][i] = -INF;
else dp[][i] = INF;
for(int i = ; cmd[i]; ++i) {
for(int k = ; k < ; ++k) dp[cur^][k] = flag?-INF:INF;
if(cmd[i] == 'F' || cmd[i] == '?') {
dp[cur^][] = op(dp[cur^][],dp[cur][]+x);
dp[cur^][] = op(dp[cur^][],dp[cur][]-y);
dp[cur^][] = op(dp[cur^][],dp[cur][]-x);
dp[cur^][] = op(dp[cur^][],dp[cur][]+y);
}
if(cmd[i] == 'L' || cmd[i] == '?') {
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
}
if(cmd[i] == 'R' || cmd[i] == '?') {
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
dp[cur^][] = op(dp[cur^][],dp[cur][]);
}
cur ^= ;
}
int ans = flag?-INF:INF;
for(int i = ; i < ; ++i)
ans = op(dp[cur][i],ans);
return ans;
}
int main() {
int cs = ;
while(~scanf("%s",cmd)) {
int max_x = go(mymax,true,,);
int min_x = go(mymin,false,,);
int max_y = go(mymax,true,,);
int min_y = go(mymin,false,,);
printf("Case %d: %d %d %d %d\n",cs++,min_x,max_x,min_y,max_y);
}
return ;
}
CSU 1510 Happy Robot的更多相关文章
- Robot Framework用户手册 (版本:3.0)
版权信息:诺基亚网络和解决中心 本翻译尊重原协议,仅用于个人学习使用 1.开始: 1.1 介绍: Robot Framework是一个基于Python的,为终端测试和验收驱动开发(ATDD)的可扩展的 ...
- selenium webdriver 右键另存为下载文件(结合robot and autoIt)
首先感谢Lakshay Sharma 大神的指导 最近一直在研究selenium webdriver右键菜单,发现selenium webdriver 无法操作浏览器右键菜单,如图 如果我想右键另存为 ...
- RIDE -- Robot Framework setup
RobotFramework 是一款基于python 的可以实现关键字驱动和数据驱动并能够生成比较漂亮的测试报告的一款测试框架 这里使用的环境是 python-2.7.10.amd64.msi RID ...
- [8.2] Robot in a Grid
Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can on ...
- Robot Framework自动化测试 ---视频与教程免费分享
当我第一次使用Robot Framework时,我是拒绝的.我跟老大说,我拒绝其实对于习惯了代码的自由,所以讨厌这种“填表格”式的脚本.老大说,Robot Framework使用简单,类库丰富,还可以 ...
- robot创建桌面图标(转载)
桌面ride图标,安装之后会自动创建(偶尔也会创建失败),创建桌面图标方法如下: 1. 新建快捷方式 在桌面右击鼠标,弹出的菜单选择 新建-快捷方式 ,然后在"请键入对象"的位置输 ...
- Robot Framework 的安装和配置(转载)
Robot Framework 的安装和配置 在使用 RF(Rebot framework)的时候需要 Python 或 Jython 环境,具体可根据自己的需求来确定.本文以在有 Python 的环 ...
- 解决从jenkins打开robot framework报告会提示‘Opening Robot Framework log failed ’的问题
最新的jenkins打开jenkins robot framework报告会提示如下 Verify that you have JavaScript enabled in your browser. ...
- 在centos7中安装Robot Framework
安装前景介绍: 最初,我们是在Windows环境下搭建Robot Framework来对我们的服务进行接口测试的(想知道如何在Windows下安装Robot Framework,可以参考我同事的博客h ...
随机推荐
- LeetCode 437. Path Sum III (STL map前缀和)
找遍所有路径,特判以根为起点的串即可. 代码: /** * Definition for a binary tree node. * struct TreeNode { * int val; * Tr ...
- POJ 1064 Cable master 【二分答案】
和杭电那一题一样,只不过G++交不能通过,C++能过 wa了好多好多好多次----------------------------------------- #include<iostream& ...
- 使用windowbuilder的时候更方便——设置默认把控件生成为成员变量而不是局部变量
找了一大圈,最后还是上Google才找到这个方法的.以前改过了,重新设置工作目录之后设置都丢失了,却找不到改的办法,这次长个记性,记在自己博客里. 设置成成员属性的好处是随后使用这些控件的时候方便.
- BZOJ 3376 [Usaco2004 Open]Cube Stacking 方块游戏(带权并查集)
题解 #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #in ...
- Java取得环境变量和系统属性
取得所有的环境变量 public class GetEnvAndProp { public static void main(String[] args) { Map<String, Strin ...
- 堆(Heap)-c实现
这个堆的实现采用数组存储的完全二叉树实现. 最近有点烦躁,先是跳槽到了一个外包公司,感觉2016有点坑,另外一件事就是老婆怀孕了,但是在家里没人照顾,很担心. 这个堆的实现就暂时不优化了,基本的插入, ...
- crontab执行脚本和手动执行脚本输出结果不一致的问题处理
背景:huskiesir最近用公司给分配的账户写了脚本去检测某应用状态并发送到企业邮箱,写完脚本之后去执行了一下,发现效果还不错,在邮箱显示效果如下: 10.11.116.6 检查结果OK,检查时间 ...
- mariadb数据库基础知识及备份
数据库介绍 1.什么是数据库? 简单的说,数据库就是一个存放数据的仓库,这个仓库是按照一定的数据结构(数据结构是指数据的组织形式或数据之间的联系)来组织,存储的,我们可以通过数据库提供的多种方法来管理 ...
- Android APP弱网测试问题和解决分析
最近做了一次移动APP的弱网和中断测试,接下来分享一下遇到的一些问题: 1.现象:用户登录应用时下载初始化数据,下载过程中因网速太慢点击取消并重新登录,数据初始化完成后出现重复,造成数据不一致. 原因 ...
- linux进程管理之进程创建(三)
在linux系统中,许多进程在诞生之初都与其父进程共同用一个存储空间.但是子进程又可以建立自己的存储空间,并与父进程“分道扬镳”,成为与父进程一样真正意义上的进程. linux系统运行的第一个进程是在 ...