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. bzoj 3926 转换+广义后缀自动机

    思路:重点在于叶子节点只有20个,我们把叶子节点提到根,把20个trie图插入后缀自动机,然后就是算有多少个本质不同的字串. #include<bits/stdc++.h> #define ...

  2. php输出多余的空格或者空行

    1,文件是否有bom.可以通过脚步检测,或者利用notepa++打开,查看编码格式. 2.  <?php echo 'something'; ?>  或许是你的php标签外,有空格或者空行 ...

  3. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  4. python装饰器原理

    妙处在于装饰器的两个return 1.装饰器 # 使用闭包 def wrap(fun): def check(): print("正在检查用户权限!") fun() return ...

  5. springBoot application.properties 基础配置

    # 文件编码 banner.charset= UTF-8 # 文件位置 banner.location= classpath:banner.txt # 日志配置 # 日志配置文件的位置. 例如对于Lo ...

  6. 【WIN10】Toast 通知

    DEMO下載:http://yunpan.cn/cFSLZQf5ePeTV  访问密码 1fce 1.顯示通知 使用xml確定通知內容. string xml = "<toast la ...

  7. bzoj1211: [HNOI2004]树的计数 prufer编码

    题目链接 bzoj1211: [HNOI2004]树的计数 题解 prufer序 可重排列计数 代码 #include<bits/stdc++.h> using namespace std ...

  8. CentOS系统下中文文件名乱码

    原文来自:http://www.zhukun.net/archives/7434 CentOS系统下中文文件名乱码 2014/09/01Linux运维centos.Linuxbear 从windows ...

  9. bzoj 3611

    和BZOJ消耗站一样,先将那个询问的简图构建出来,然后就是简单的树形DP. (倍增数组开小了,然后就狂WA,自己生成的极限数据深度又没有那么高,链又奇迹般正确) #include <cstdio ...

  10. js的继承实现方式

    1. 使用call或者apply来实现js对象继承 function Animal(age){ this.age = age; this.say = function(){ console.log(' ...