Usaco_Contest_2013_Open_Bovine Problem 1. Bovine Ballet
Problem 1: Bovine Ballet [Brian Dean, 2013]
In an attempt to challenge the stereotypical perception of cows as awkward
creatures, Farmer John's prize cow Bessie has signed up for an introductory
ballet class. Her final performance is next week, and FJ wants to help her
by building a rectangular stage large enough so that she can perform her
entire dance without falling off the edges.
Bessie's dance will take place on a rectangular stage consisting of a grid
of 1 x 1 square cells. Bessie's four feet are described concisely as follows:
FR: Front right foot
FL: Front left foot
RR: Rear right foot
RL: Rear left foot
Her four feet start out in 4 adjacent cells forming a square as follows,
with Bessie facing north.
FL FR
RL RR
Bessie's dance follows a series of N instructions (1 <= N <= 1000), where
each instruction tells her to either move one foot by one cell or to pivot
90 degrees clockwise.
Instructions to move a foot consist of 3 characters, the first two
identifying the foot to move, and the final character specifying the
direction of movement (F = forward, B = back, R = right, L = left). For
example, "FRF" means Bessie should move her front right foot forward one
cell, and "RLR" means she should move her rear left foot right one cell.
Of course, the direction of movement is relative to the direction Bessie is
facing.
Instruction to pivot are also 3 characters, the first two specifying the
single foot that Bessie keeps planted, around which she rotates 90 degrees
clockwise. The last character is "P" (for pivot). For example, the
instruction "FRP" means Bessie should pivot 90 degrees clockwise about her
stationary front right foot. This means that if her feet are currently
situated as follows (with Bessie facing north)
.. .. ..
.. .. FR
.. FL ..
.. RL RR
then the after the instruction "FRP" her feet will be located as follows,
with Bessie now facing east:
RL FL ..
RR .. FR
.. .. ..
.. .. ..
Given the N instructions in Bessie's dance, please compute the minimum area
of a rectangular stage necessary contain her feet during the entire dance.
If Bessie clumsily ever moves one foot onto the same cell as another foot,
she will trip and fail to complete the dance; in this case, please output
-1. Note that this is the only case where Bessie will trip; she has become
quite flexible after all her practice, and can easily move her feet into
rather strange configurations (for example, with her back feet farther
forward than her front feet).
PROBLEM NAME: ballet
INPUT FORMAT:
* Line 1: The integer N.
* Lines 2..1+N: Each line contains one of the 3-character instructions
in Bessie's dance.
SAMPLE INPUT (file ballet.in):
3
FRF
FRP
RLB
INPUT DETAILS:
Bessie's dance consists of the instructions "front right foot forward",
"front right foot pivot", and "rear left foot back".
OUTPUT FORMAT:
* Line 1: The minimum area of a rectangular stage necessary to contain
Bessie's feet during the entire dance, or -1 if Bessie trips.
SAMPLE OUTPUT (file ballet.out):
16
OUTPUT DETAILS:
Bessie needs a 4 x 4 stage to complete her dance. Her feet move as follows:
.. .. .. ..
.. .. .. .. (facing north)
.. .. FL FR
.. .. RL RR
After FRF:
.. .. .. ..
.. .. .. FR (facing north)
.. .. FL ..
.. .. RL RR
After FRP:
.. RL FL ..
.. RR .. FR (facing east)
.. .. .. ..
.. .. .. ..
After RLB:
RL .. FL ..
.. RR .. FR (facing east)
.. .. .. ..
.. .. .. ..
Usaco_Contest_2013_Open_Bovine Problem 1. Bovine Ballet的更多相关文章
- 洛谷P3611 [USACO17JAN]Cow Dance Show奶牛舞蹈
题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance p ...
- 1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区(题解第二弹)
1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: ...
- 1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区(题解第一弹)
1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
随机推荐
- 牛客练习赛29 B
炎热的早上,gal男神们被迫再操场上列队,gal男神们本来想排列成x∗x的正方形,可是因为操场太小了(也可能是gal男神太大了),校长安排gal男神们站成多个4∗4的正方形(gal男神们可以正好分成n ...
- CDH4 journalnode方式手工安装手册之三
一. 启动JournalNode 每台机器都要执行: mkdir -p /smp/hadoop-cdh4/bch/ chmod -R 77 ...
- Splay的用法
splay区间增减查询 #include<cstdio> #include<algorithm> using namespace std; ; const int INF = ...
- python基础学习笔记——字符串方法
索引和切片: 索引:取出数组s中第3个元素:x=s[2] 切片:用极少的代码将数组元素按需处理的一种方法.切片最少有1个参数,最多有3个参数,演示如下: 我们假设下面所用的数组声明为array=[2, ...
- LoadRunner 手动关联
步骤: 1.同样的流程录制两遍,保存在不同的项目中, 2.点击Tools >> Compare with Script 3.选择要比对的脚本 3.找辨识码 4.打开辨识码所在网页,查看源代 ...
- python 查看异常
接触python 一直觉着编译后报错经常没能捕捉显示,每次也只能从头看到尾 恰好在水木社区中看到关于异常捕捉帖子 方法一:捕获所有异常 try: a=b b=c except Exception,ex ...
- linux内核代码注释 赵炯 第三章引导启动程序
linux内核代码注释 第三章引导启动程序 boot目录中的三个汇编代码文件 bootsect.s和setup.s采用近似intel的汇编语法,需要8086汇编器连接器as86和ld86 head ...
- Java生产者消费者模式
为什么要使用生产者和消费者模式 在线程世界里,生产者就是生产数据的线程,消费者就是消费数据的线程.在多线程开发当中,如果生产者处理速度很快,而消费者处理速度很慢,那么生产者就必须等待消费者处理完,才能 ...
- 【bzoj2729】[HNOI2012]排队 组合数学+高精度
题目描述 某中学有 n 名男同学,m 名女同学和两名老师要排队参加体检.他们排成一条直线,并且任意两名女同学不能相邻,两名老师也不能相邻,那么一共有多少种排法呢?(注意:任意两个人都是不同的) 输入 ...
- IDA Pro使用技巧及大杂烩
IDA Pro使用技巧及大杂烩 IDA Pro基本简介 IDA加载完程序后,3个立即可见的窗口分别为IDA-View,Named,和消息输出窗口(output Window). IDA图形视图会有执行 ...