Time Limit: 3000MS     64bit IO Format: %lld & %llu

Submit Status uDebug

  You are attempting to learn to play a simple arcade dancing game. The
game has 4 arrows set into a pad: Up, Left, Down, Right. While a song
plays, you watch arrows rise on a screen, and when they hit the top, you
have to hit the corresponding arrows on the pad. There is no penalty for
stepping on an arrow without need, but note that merely standing on an
arrow does not activate it; you must actually tap it with your foot. Many
sequences in the game are very fast-paced, and require proper footwork
if you don’t want to tire yourself out. Write a program to determine the
easiest way to execute a certain sequence of arrows.
  We will work with a basic time unit of an eighth-note. At any given time, your left foot and right
foot will each be on distinct arrows. Only one foot may perform an action (changing arrows and/or
tapping) during any time unit; jumping is not allowed. Also, you must remain facing forward in order
to see the screen. This puts limitations on which feet you can use to hit which arrows. Finally, hitting
two arrows in a row with the same foot (“double-tapping”) is exhausting, because you can’t shift your
weight onto that foot. Ideally, you want to alternate feet all the way through a string of consecutive
arrows.
  Performing an action with a foot costs 1 unit of energy if it did NOT
perform an action in the previous time unit. If it did, then it costs 3 units
if it doesn’t change arrows, 5 units if it moves to an adjacent arrow, and
7 units if it moves directly across the pad (between Up and Down, or Left
and Right).
  Under normal circumstances, you can’t put your left foot on Right, or
your right foot on Left. However, you CAN do a temporary “crossover”:
if your left foot is on Up or Down, you can twist your hips and put your
right foot on Left — but until your right foot moves away, you can’t move
your left to a different arrow. (Imagine the tangle your legs would get into
if you tried!) Similarly, you can cross your left foot over/behind your right.
Input
You will be given multiple arrow sequences to provide foot guides for.
Every sequence consists of a line containing from 1 to 70 characters, representing the arrow that must
be hit at each time unit. The possible characters are ‘U’, ‘L’, ‘D’, and ‘R’, signifying the four arrows, or
a period, indicating that no arrow need be hit. Assume that your left and right feet start on the Left
and Right arrows for the first time unit of a sequence.
There are at most 100 sequences. Input is terminated by a line consisting of a single ‘#’.
Output
For each input sequence, output a string of the same length, indicating which foot should perform an
action at each time step, or ‘.’ if neither does. If there are multiple solutions that require minimal
energy, any will do.
Sample Input
LRLRLLLLRLRLRRRRLLRRLRLDU...D...UUUUDDDD
#
Sample Output
LRLRLLLLRLRLRRRRLLRRLRLRL...R...LLLLRRRR

——————————————————我是分割线————————————————————

DP题目

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<iomanip>
#include<cassert>
#include<climits>
#include<functional>
#include<bitset>
#include<vector>
#include<list>
#define maxn 100001
#define F(i,j,k) for(int i=j;i<=k;i++)
#define M(a,b) memset(a,b,sizeof(a))
#define FF(i,j,k) for(int i=j;i>=k;i--)
#define inf 0x3f3f3f3f
#define maxm 1001
#define mod 998244353
//#define LOCAL
using namespace std;
int read(){
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
const int LEFT=;
const int RIGHT=;
const int MAXN=;
int n;
int d[MAXN][][][];
char seq[MAXN];
int action[MAXN][][][];
char place[]=".LR";
int pos[];
int energ(int a,int ta)
{
if (a==ta) return ;
if (a+ta==) return ;
return ;
}
int energy(int a,int b,int s,int f,int t,int &ta,int &tb)
{
ta=a;
tb=b;
if (f==) ta=t;
else if(f==) tb=t;
if (ta==tb) return -; // 下一个状态猜到同一个位置
if (ta==RIGHT&&tb==LEFT) return -; // 背向跳舞机
if(a==RIGHT&&tb!=b) return -; // a左脚在右脚的位置,但是移动了右脚,无论移动到哪儿,都是不合法的
if(b==LEFT&&ta!=a) return -;
int e=;
if(f==) e=;
else if(f!=s) e=;
else
{
if (f==) e=energ(a,ta);
else e=energ(b,tb);
}
return e;
}
void update(int i,int a,int b,int s,int f,int t)
{
int ta,tb;
int e;
e=energy(a,b,s,f,t,ta,tb);
if (e<) return;
int cost=d[i+][ta][tb][f]+e;
int &ans=d[i][a][b][s];
if (ans>cost)
{
ans=cost;
action[i][a][b][s]=f*+t;
}
}
void solve()
{
n=strlen(seq);
memset(d,,sizeof(d));
for(int i=n-;i>=;i--)
for(int a=;a<;a++)
for(int b=;b<;b++){
if(a==b) continue;
for(int s=;s<;s++)
{
d[i][a][b][s]=0x1f1f1f1f;
if (seq[i]=='.')
{
update(i,a,b,s,,);
for(int t=;t<;t++)
{
update(i,a,b,s,,t);
update(i,a,b,s,,t);
}
}
else
{
update(i,a,b,s,,pos[seq[i]]);
update(i,a,b,s,,pos[seq[i]]);
}
}
}
int a=;
int b=;
int s=;
for (int i=;i<n;i++)
{
int f=action[i][a][b][s]/;
int t=action[i][a][b][s]%;
cout<<place[f];
s=f;
if(f==) a=t;
else if(f==) b=t;
}
cout<<endl;
//cout<<d[0][1][2][0]<<endl;
}
int main()
{
std::ios::sync_with_stdio(false);//cout<<setiosflags(ios::fixed)<<setprecision(1)<<y;
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
pos['U']=;
pos['D']=;
pos['L']=;
pos['R']=;
while(cin>>seq)
{
if (seq[]=='#')
break;
solve();
}
return ;
}

uva 10618 Tango Tango Insurrection 解题报告的更多相关文章

  1. 【Uva 10618】Tango Tango Insurrection

    [Link]: [Description] 玩跳舞机. 有一定的约束. 归纳起来就是以下三点 1.两只脚不能同时踩一个位置 2.如果左脚踩在了右键上,那么下一次移动的一定要是左脚 3.如果右脚踩在了左 ...

  2. uva 10881 Piotr's Ants 解题报告

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=20&pa ...

  3. UVA 12538 Version Controlled IDE 解题报告

    题意:给三种操作 1.在p位置插入一个字符串. 2.从p位置开始删除长度为c的字符串 3.输出第v个历史版本中从p位置开始的长度为c的字符串 解法:可以用平衡树做,但是不会.后来又听说可一用一个叫ro ...

  4. UVa 455 - Periodic Strings - ( C++ ) - 解题报告

    1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过 ...

  5. Uva 106 - Fermat vs. Pythagoras 解题报告

    数论题,考查了本原勾股数(PPT) 对一个三元组(a,b,c)两两互质 且满足 a2 + b2 = c2 首先有结论 a 和 b 奇偶性不同 c总是奇数(可用反证法证明,不赘述) 设 a为奇数 b为偶 ...

  6. 【暑假】[深入动态规划]UVa 10618 Tango Tango Insurrection

    UVa 10618 Tango Tango Insurrection 题目: Problem A: Tango Tango Insurrection You are attempting to lea ...

  7. 【杂题总汇】UVa-10618 Tango Tango Insurrection

    [UVa-10618] Tango Tango Insurrection ◇ 题目 +vjudge 链接+ (以下选自<算法竞赛入门经典>-刘汝佳,有删改) <题目描述> 你想 ...

  8. 2020.6.16 night 解题报告

    2020.6.16 night 解题报告 link 标签(空格分隔): 题解 概率与期望 T1 : Crossing Rivers UVA - 12230 SB题. 很唬人的一个连续期望. 很明显,在 ...

  9. CH Round #56 - 国庆节欢乐赛解题报告

    最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...

随机推荐

  1. 成功实施的APS项目故事分享---如何管理与激励APS项目团队

    故事背景 A企业是易普优APS重要客户之一,是某行业的龙头企业:APS项目历时7个月顺利上线,十个月验收!通过易普优APS的顺利实施,建成了集团的精益计划管控运营平台,树立计划的权威与指挥棒作用,让物 ...

  2. 使用Caffe训练适合自己样本集的AlexNet网络模型,并对其进行分类

    1.在开始之前,先简单回顾一下几个概念. Caffe(Convolution Architecture For Feature Extraction-卷积神经网络框架):是一个清晰,可读性高,快速的深 ...

  3. nginx配置web服务器

    一:设置虚拟服务器 1.设置 http { server { listen 127.0.0.1:8080; server_name example.org www.example.org; } } 2 ...

  4. 全面兼容的Iframe 与父页面交互操作

     父页面 Father.htm 源码如下:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" & ...

  5. Ionic实战七:Ionic 音乐以及社交页面

    Ionic 音乐以及社交页面,可以用于二次开发,也可以用于社交或者音乐app页面模板,但是不足的是图片没法预览.      

  6. structs2的action实现方式

    Action的实现方式第一种:在web.xml中添加配置<filter> <filter-name>struts2</filter-name> <filter ...

  7. CodeDom生成类文件

    仅供个人学习 需要先引入System.CodeDom nuget包 using CodeGenerate.Entities; using System; using System.CodeDom; u ...

  8. 学会使用DNSPod,仅需三步

    学会使用DNSPod,仅需三步   第一步:在DNSPod添加记录 1.访问 https://www.dnspod.cn网站,在DNSPod官网首页的右上角,有[注册],如下图所示,点击[注册]按钮 ...

  9. Python csv模块的使用

    1.csv简介 CSV (Comma Separated Values),即逗号分隔值(也称字符分隔值,因为分隔符可以不是逗号),是一种常用的文本 格式,用以存储表格数据,包括数字或者字符.很多程序在 ...

  10. window下完全删除nodejs

    1.从卸载程序卸载程序和功能. 2.重新启动(或者您可能会从任务管理器中杀死所有与节点相关的进程). 3.寻找这些文件夹并删除它们(及其内容)(如果还有).根据您安装的版本,UAC设置和CPU架构,这 ...