随笔分类 -  基本算法—模拟

摘要:题目链接题意:给N条信息,每个信息代表有x个人从开始的时间 到 结束的时间在餐厅就餐,问最少需要多少座位才能满足需要。分析:由于时间只有24*60 所以把每个时间点放到 数组a中,并标记开始的时间+x,结束的时间 -x。最后累加比较。如果时间点太多的时候可以把时间点放到结构体里,排序,然后依次枚举结... 阅读全文
posted @ 2014-07-28 17:19 水门 阅读(220) 评论(0) 推荐(0)
摘要:题目题意:在三维坐标系中,给定n个立方体的中心坐标,立方体的边长为1,按照输入顺序,后来输入的必须和之前输入的立方体有公共的边。而且,不能和之前输入的立方体相同。如果满足条件,输出表面积。如果不满足,输出不符合条件的那一组。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 struct node10 {11 int x, y, z;12 }p[110], m;13 int dx[10] = {0,0,0,0,1,-1};14 int d... 阅读全文
posted @ 2014-04-03 20:39 水门 阅读(195) 评论(0) 推荐(0)
摘要:题目上次比赛的题目,好长时间了。这几天感冒了很难受, 直到现在才整理,上次比赛的时候,出了各种错误, ,,,样例都没过,题目读的也很差,今天做的时候,看了一下网上的,发现一个代码特别简洁,学习了一下。不过,在hdu交的时候,交c++会编译错误,不知道怎么回事,两次了,G++能过。题意:给n个字符串和它们代表的值,求下面m个式子是否成立。字符串对应的值有一位小数, 式子上的值是整数 (比赛的时候根本 没注意这个) 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace s... 阅读全文
posted @ 2014-04-01 01:42 水门 阅读(267) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3393一道题目挺长的模拟题,参考了网上大神的题解。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int Month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 8 int Lmonth[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; 9 10 int check(int year) 11 { 12 if(year1... 阅读全文
posted @ 2014-01-17 23:05 水门 阅读(211) 评论(0) 推荐(0)
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2721题意:给定n个左标,跟那n个坐标相同的 且3个以上的消失,圈都 靠下, 而且 如果一整列都没有的话,就都往左靠。。。。思路:比赛的时候没调试完,,,, 最坑爹的是,用后台数据测试都对了,结果还是wrong, 经过鑫哥指导。。。那些字符要以字符串的形式输入,否则会wrong ,后台的原因不知道为什么。。。 1 #include 2 #include 3 #include 4 #include 5 using namespac... 阅读全文
posted @ 2013-12-01 21:35 水门 阅读(355) 评论(0) 推荐(0)
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2718题意:优先直走,右 左 后。。。。思路:我定义的朝向 已经 d[]的先后次序。。。。。3214 1 #include 2 #include 3 using namespace std; 4 5 int dx[5]={0,1,-1,0,0}; 6 int dy[5]={0,0,0,1,-1}; 7 struct node 8 { 9 int x,y,tow,step; 10 }pos,before; 11 in... 阅读全文
posted @ 2013-12-01 20:41 水门 阅读(332) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3087题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s1,最顶的c块牌归为s2,依此循环下去。现在输入s1和s2的初始状态 以及 预想的最终状态s12问s1 s2经过多少次洗牌之后,最终能达到状态s12,若永远不可能相同,则输出"-1"。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 阅读全文
posted @ 2013-08-27 09:57 水门 阅读(175) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=2993题意:和2996反着 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 struct node12 {13 int x,y;14 char ch;15 }q[1000];16 bool cmp(node a,node b)17 {18 if(a.x!=b.x) return a.x>b.x;19 return a.y... 阅读全文
posted @ 2013-08-05 16:02 水门 阅读(277) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=2996题意:给出 棋盘 情况 输出 白棋 和 黑棋在 棋盘上的 白棋为大写字母 黑棋为小写字母 棋盘 左下点为原点(1,a) 输出 是 按照KQRBNP的顺序白棋 输出 行小的 行相同按列小的 先输出 黑棋 行大的先输出 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 11 struct node12 {13 int p,x,y;14 cha... 阅读全文
posted @ 2013-08-05 10:57 水门 阅读(218) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1573题意:已知坐标系大小,和初始的最上面的位置,根据命令求是否能出去,或者一直循环这就是我建的系,画的有点难看哈! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 char map[500][500];11 int vis[500][500];12 13 int dx[5]={0,0,-1,1};//分别代表N,S,W,E14 int dy[5]={1,-. 阅读全文
posted @ 2013-07-31 19:57 水门 阅读(207) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=2632题意:已知仓库大小,告诉机器人的起始位置和方向,告诉m条指令,求按指令会不会撞墙或撞机器人。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int map[110][110]; 9 int dx[5]={0,1,0,-1};10 int dy[5]={1,0,-1,0};11 struct node12 {13 int x,y,d;//d与dx,dy数组记录方向14 }rob[1000];15 int... 阅读全文
posted @ 2013-07-31 15:20 水门 阅读(198) 评论(0) 推荐(0)
摘要:一个水题,全是小错误,整了一下午。题目:http://poj.org/problem?id=1068题意:给出一组括号: (((()()())))P是”)“前面有几个“(”: 4 5 6 6 6 6S是“)”前面第几个“(”是对应的: 1 1 1 4 5 6让你根据给出的P求对应的S 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 int n,i,t,a[1500],b[1500]... 阅读全文
posted @ 2013-07-30 19:25 水门 阅读(174) 评论(0) 推荐(0)