hdu 2577 模拟】的更多相关文章

#include<stdio.h> #define N 200 char s[N]; int judgeup(char c) { if(c>='A'&&c<='Z') return 1; return 0; } int judgelo(char c) { if(c>='a'&&c<='z') return 1; return 0; } int main() { int lock,i,j,sum,n,h; scanf("%d&qu…
题目转自hdu 2577,题目传送门 题目大意: 现给你n个区分大小写的字符串,大小写可用Caps Lock和shift切换(学过计算机的都知道) 但是有一点需要注意(shift是切换,若现在是大写锁定,用shift可切换成小写) 解题思路: 这道题一开始拿的时候,就觉得是n2的dp 但是,转移方程一直没想出来(0.25h) 后来又仔细想想,发现是2n的dp 然后想了想,20min就切了 我们先将字符串做预处理,形成一个01字符串 像这个测试数据: HELlowORLd 可以转换成这样: 然后,…
http://acm.hdu.edu.cn/showproblem.php?pid=2577 大意: 大家都打过字吧,现在有个有趣的问题:给你一串字符串,有大写有小写,要求你按键次数最少来输出它,输出按键次数. 大写字母可以通过caps lock 也可以用shift得到,小写也是. 但是起始状态和最后caps lock都是不锁定的. 求最少的按键次数. 思路: 不用DP的方法: 当有连续的大写或者小写用caps lock 键,否则用shift. #include<cstdio> #includ…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2577 解题报告:有一个长度在100以内的字符串,并且这个字符串只有大写和小写字母组成,现在要把这些字符串用键盘输入到电脑中,一开始的时候大写锁定是关闭的,并且要求结束的时候也是关闭的,然后让你求输入这些字符串最少需要按多少次键盘(包括Cap Lock键和Shift键) 一个典型的dp题,定义一个一维数组就够了,然后dp[i]的含义的输入到第i个字符时需要按键的最少次数.然后递推公式如下: dp[i]…
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn+1), si表示连续的空格数. 2.{}中间,即 | 的个数+1. 就是模拟 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <…
http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <queue> #include <vector> #include <i…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4616    Accepted Submission(s): 2084 Problem Description Pirates have finished developing the typing software. He called Cathy to tes…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6072    Accepted Submission(s): 2729 Problem Description Pirates have finished developing the typing software. He called Cathy to tes…
题意 (我做了这题才知道caps lock 锁定大小写后,按一下shift键可以输入相反的大小写.) 这题就是给你只有大小写字母的字符串,求最少多少次按键盘.最后caps lock 必须是关闭的. 分析 这题可以模拟也可以dp. 代码 模拟 #include<cstdio> #include<cstring> int t,on,i,ans; char s[105]; int isU(char a) { return a<='Z'&&a>='A'; } i…
思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring>…
The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 389    Accepted Submission(s): 153 Problem Description There was no donkey in the province of Gui Zhou, China. A trouble m…
题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef…
http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include…
http://acm.hdu.edu.cn/showproblem.php?pid=5033 平面上有n个建筑,每个建筑由(xi,hi)表示,m组询问在某一个点能看到天空的视角范围大小. 维护一个凸包,据说可以用单调栈 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <set> #in…
How to Type Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6787    Accepted Submission(s): 3057 Problem Description Pirates have finished developing the typing software. He called Cathy to test…
Regroup Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1057    Accepted Submission(s): 297 Problem Description When ALPC42 got to a panzer brigade, He was asked to build software to help them r…
Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 991    Accepted Submission(s): 244 Problem Description Nowadays, Jim Green has produced a kind of computer called JG. In his computer,…
Bob and math problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1481    Accepted Submission(s): 552 Problem Description Recently, Bob has been thinking about a math problem.There are N Digi…
郑厂长系列故事——逃离迷宫 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1817    Accepted Submission(s): 840 Problem Description 郑厂长没变 还是那个假厂长真码农 改变的是业余爱好 他现在不研究象棋,改玩游戏了! 最近,郑厂长爱上了逃离迷宫这个游戏,他日日夜夜的玩,就是想达到自己的…
/* 模拟: 注意:实质上一次魔方的一半要变化 用c++超内存 用g++过了 */ #include<stdio.h> #include<string.h> #include<queue> #include<algorithm> using namespace std; struct node { int f0[4],f4[4],f6[4],f8[4],f16[4],f20[4]; int step; } s,next; int fnow[10000][6]…
考察英语的题 - -# 按条件模拟,一遍即可了,每一个聊天对象有其价值U.数组模拟队列过程即可,若存在Top标记,则和Top标记的人聊天,否则和队列的第一个人聊天 mark记录队尾,top记录Top操作,data[i].p记录U,data[i].x记录chat数.data[i].y记录该人是否被删除 Add U:在 队尾插入价值为U的人,须要特判U人已经存在 Close U::在整个队列中查找价值为U的人,将其删除.须要特判该人不存在 Chat x:当前聊天页面的人chat+=x,特判当前队列没…
题意:       给你一个串,问你有几种意思,有两个规则 (1) { }  答案乘以  ({}之间"|"的个数 + 1)  (2)  &&   答案乘以  (&&之间连续的' '的个数 + 1) 比如 {aa|dsd|}dasdaddda&   a  &的答案是      (2 + 1)    *  (3+1) *(2 + 1) = 36 思路:     直接模拟,结果我自己sb了wa了很多次,记得开INT64 ,为什么开,自己模拟下最…
题意:要求一个字符串输入,按键盘的最少次数.有Caps Lock和Shift两种转换大小写输入的方式 思路:用dpa与dpb数组分别记录Caps Lock的开关状态,dpa表示不开,dpb表示开 代码: #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; char str[111]; int dpa[111],dpb[111]; int main() { int…
Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 78    Accepted Submission(s): 12 Problem Description Mr. Frog learned a basic data structure recently, which is called stack.…
题意:给出一个字符串,有大写有小写,问最少的按键次数.然后打字的这个人有一个习惯,打完所有的字之后,指示灯要关闭. dp[i][j]表示打到第i个字母,j有0,1两个值表示指示灯开或者关的状态 然后就可以写出状态转移方程了,因为最后需要灯是灭的,所以最后在找最小值的时候,dp[len][1]需要加1 又一次看的题解===go--go #include<iostream> #include<cstdio> #include<cstring> #include<alg…
题意: 打字游戏,求所按的最少次数.给出一个串,其中有大小写,大写需要按下cap键切换到大写,或者在小写状态下按shift+键,这样算两次,打小写时则相反.注意:在打完所有字后,如果cap键是开着的,要关它,也就是要算多一次. 思路: DP,根据每个字符打完后cap键盘是开着的还是关着的,最后dp[最后一个字符][关着的]为答案.规模降低到1个字符,每次考虑增加一个字符,打这个字符有两种选择,从上一个字符打完后的cap键关/开的两种状态来按下此字符,按完此字符后考虑使cap键开着或者关掉. dp…
九野的博客,转载请注明出处:http://blog.csdn.net/acmmmm/article/details/11711743 题意:驴和老虎在方格中跑,跑的方式:径直跑,若遇到边界或之前走过的点则转向,驴向右转,虎向左转,若转向后还不能跑则一直呆着不动, 问:他们是否会相遇,会输出相遇坐标,不会输出-1 #include <iostream> #include <algorithm> #include <cstdlib> #include <cstring…
给出五子棋残局,推断三步内能否分出胜负,玩家为当前该走旗子的颜色,下一步为白棋或黑棋不定. 依照顺序推断就可以: 1:推断棋盘是否合法,并确定玩家颜色 2:推断当前玩家颜色是否有一个必胜点,有玩家则在第一步胜 3:推断还有一方在当前是否有两个必胜点,若有,则玩家在第二步失败 4:BFS出玩家是否存在此方案:随意放置一个位置的前提下,还有一方没有必胜点,且玩家有两个必胜点,则玩家在第三步胜 5:否则3步内无法分出胜负 #include "stdio.h" #include "s…
连续最大积 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 699    Accepted Submission(s): 275 Problem Description 小明和他的好朋友小西在玩一个游戏,由电脑随机生成一个由-2,0,2三个数组成的数组,并且约定,谁先算出这个数组中某一段连续元素的积的最大值,就算谁赢! 比如我们有如下随…
题意是说给定一个 2*2 魔方的各个面的情况,问是否能转动不超过一次使得魔方复原. 思路是先在输入的时候统计一下已完成的面数,要想以最多一次的转动使得魔方复原,那么已完成的面数只能是 2 面或者 6 面,此处可剪枝. 若已完成 6 面,那么一定可以复原: 若已完成 2 面,则要用一次转动完成其他六面,开始这里打算用结构体去存,结果在判断的时候自己混乱了……最终直接定了 24 个变量,a,b,c……w,x, 手动做了个小正方体,太丢人……(但不得不说这种方法挺好的,易于理解,而且不会乱^_^) 代…