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 ...
随机推荐
- sqlserver 恢复模式及避免日志爆满的方法
recovery simple 循环日志,空间自动回收,不可备份日志,恢复时仅能恢复到数据库备份时间点: 用于落地数据或测试环境或OLAP,不推荐用于生产OLTP 有时候distribution过大也 ...
- 利用SQL索引提高查询速度
1.合理使用索引 索引是数据库中重要的数据结构,它的根本目的就是为了提高查询效率.现在大多数的数据库产品都采用IBM最先提出的ISAM索引结构. 索引的使用要恰到好处,其使用原则如下: 在经常进行连接 ...
- swift中高阶函数map、flatMap、filter、reduce
Swift相比于Objective-C又一个重要的优点,它对函数式编程提供了很好的支持,Swift提供了map.filter.reduce这三个高阶函数作为对容器的支持. 1 map:可以对数组中的每 ...
- SP10628 COT - Count on a tree 主席树
Code: #include<cstdio> #include<cstring> #include<algorithm> #include<string> ...
- VC++ 借助 Win32 API 绘图实现基本的细胞自动机演示
//本程序使用 Visual Studio 2015 生成的 Win32 窗口程序模板 开发//使用 Win32 API 绘图//实现基本的细胞自动机演示////目前已知问题://存在内存泄漏,但具体 ...
- 异步调用task
异步主要用来提升程序性能,会增加系统的开销(新建一个线程去执行异步任务). 可应用于耗时长的操作,比如:访问数据库时(应用程序和数据库不在同一台服务器上).服务之间的调用(服务会分散在不同的服务器上) ...
- 本地yum源安装docker
Directory listing for / audit-libs-python-2.7.6-3.el7.x86_64.rpm checkpolicy-2.5-4.el7.x86_64.rpm co ...
- VUEJS开发规范
VUEJS开发规范 基于组件化开发理解 组件命名规范 结构化规范 注释规范 编码规范 基于组件化开发理解 什么是组件? ``` 组件其实就是页面组成的一部分,好比是电脑中的每一个元件(如硬盘.键盘.鼠 ...
- pandas 1 基本介绍
import numpy as np import pandas as pd pd.Series() 构造数据 s = pd.Series([1, 3, 5, np.nan, 44, 1]) prin ...
- SSH的理解
SSH的利用,通俗的讲就是一个网络传输数据的加密协议,目前有一些基于SSH的构建了服务器-客户端的软件工具,在Windows上装一个客户端,Linux上则为服务端,这样就可以把Windows上写的内容 ...