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的更多相关文章

  1. 洛谷P3611 [USACO17JAN]Cow Dance Show奶牛舞蹈

    题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance p ...

  2. 1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区(题解第二弹)

    1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit:  ...

  3. 1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区(题解第一弹)

    1675: [Usaco2005 Feb]Rigging the Bovine Election 竞选划区 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit:  ...

  4. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  5. 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 ...

  6. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  7. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  8. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  9. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

随机推荐

  1. matplotlib学习记录 五

    # 绘制电影票房竖条形图 from matplotlib import pyplot as plt a = ["战狼2","速度与激情8","功夫瑜伽 ...

  2. Python学习笔记:wxPython(GUI图形用户界面)

    wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...

  3. Linux异常处理体系结构

    arm11处理器裸机的异常与中断处理参考: [OK6410裸机程序]异常处理 [OK6410裸机程序]按键中断 另外参考一篇:Linux中断体系结构 在ARM V4及V4T以后的大部分处理器中,中断向 ...

  4. Java中对象方法的调用过程&动态绑定(Dynamic Binding)

    Java面向对象的最重要的一个特点就是多态, 而多态当中涉及到了一个重要的机制是动态绑定(Dynamic binding). 之前只有一个大概的概念, 没有深入去了解动态绑定的机理, 直到很多公司都问 ...

  5. nuc 第二届山西省大学生程序设计大赛 魔力手环

    problem 很妙啊--发现状态转移矩阵每一行都可以由上一行平移得到,每次只算第一行然后平移,\(O(n^3)\) 就变成了 \(O(n^2)\). #include <iostream> ...

  6. 【bzoj3207】花神的嘲讽计划Ⅰ Hash+STL-map+莫队算法

    题目描述 背景 花神是神,一大癖好就是嘲讽大J,举例如下: “哎你傻不傻的![hqz:大笨J]” “这道题又被J屎过了!!” “J这程序怎么跑这么快!J要逆袭了!” …… 描述 这一天DJ在给吾等众蒟 ...

  7. APIO2018 题解

    坑了好久,补一补. 话说我当时去参加 $APIO2018$ 了,不过纯粹打铁…… 我的程序交道人家毛子的网站上, $c++14$ 编译器不停地给我编 $RE$,只记得好像是结构体排序的问题(删掉那个排 ...

  8. hdu 1979 剪枝暴搜

    Fill the blanks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  9. 【CF1023C】Bracket Subsequence(模拟)

    题意:给定一个正则括号序列 s ,让你在当中选择一个长度正好为 t 的子串,使得 t 恰好也是一个正则括号序列 思路:用栈模拟 #include<cstdio> #include<c ...

  10. luogu 3708 koishi的数学题 递推 线性筛

    题目链接 题意 输入一个整数\(n\)\((n\leq 1e6)\),设\(f(x)=\sum_{i=1}^n x\mod i\),你需要输出\(f(1),f(2)...,f(n)\). 输入输出格式 ...