![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模拟
文章平均质量分 69
子在梦中曰
程序是蓝色的诗
展开
-
hdu 4495 Rectangle(模拟)
我的算法很黄很暴力。 符合题目要求的三角形一共有四种形状,对着四种形状分别计算一遍,需要注意的是对于这四个不同的三角形计算的时候遍历的方向是不同的。 wa了十几遍,一直没有发现这个地方写错了,修改后1234msAC。 #include #include #define N 505 char map[N][N]; int dp[N][N]; int m,n; void Init() {原创 2013-11-28 13:37:27 · 890 阅读 · 0 评论 -
hdu 4213 Sokoban(模拟)
一道比较简单的模拟题,不过不知道之前为什么没有做出来。 记录w所在的位置,对于w的下一个动作所影响的位置进行判断,如果下一个位置是‘b'或’B',还要对下下个位置进行判断。 #include #include #define N 16 int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; char map[N][N],s[56]; int m,n; int x,原创 2013-11-27 07:46:35 · 521 阅读 · 0 评论 -
hdu 4431 Mahjong(dfs+模拟)
前前后后提交了十几遍,终于A掉了。 在判断七小对的时候,一个牌出现四张不能当作两个对子。 然后就是各种细节。 #include #include #include #define N 35 int flag[N],mark[N],ans[N]; int cmp(const void *a,const void *b) { return *(int *)a-*(int *)b; }原创 2013-11-11 00:09:38 · 529 阅读 · 0 评论 -
hdu 2142 disney(模拟)
比赛的时候这个题目一直做不出来,WA了很多遍。比赛结束之后看别人的代码,发现竟然还需要排序! 经过我长久的思考,我终于发现了问题的所在,原来题目中的Lexicographicly是字典序的意思,这特么的! 排序之后,AC。 #include #include #include struct node { char name[15]; int score; int id原创 2013-04-22 08:08:43 · 987 阅读 · 0 评论 -
hdu 1495Legal or Not(搜索+模拟)
刚开始我以为这是一道类似于博弈的题目,还在那儿思考有没有什么办法直接推出答案,看了别人的代码才知道这题没啥好办法,老老实实的模拟才是王道。 应该说是很有意思的搜索,每次根据之前的三个杯子的不同状态产生下一个状态,一直到搜索到结果或者返回-1为止。 #include #include #include using namespace std; #define N 101 int map[N][N原创 2013-05-08 20:31:15 · 549 阅读 · 0 评论 -
hdu 4121 Xiangqi(模拟)
wa了N多遍。。。 开始的时候是模拟老将走的四个点,对这四个点分别做一次检查,然后一直wa,还一直找不到哪儿错了。 然后对所有“危险点”打表,结果因为读入用的是%c不是%s错了一次。 话说一直觉得这种读入一个字符的题目中有各种各样的空格,然后读入一个字符各种莫名wa挺坑爹的。 #include #include #define N 11 struct point { int x原创 2013-10-30 14:48:21 · 531 阅读 · 0 评论 -
hdu 4119 Isabella's Message(模拟+字典树)
这题有点儿烦! 模拟赛的时候写了快两个小时,终于A掉了。 #include #include #include #include #define N 105 char map1[N][N],map2[N][N],s[2505]; char s1[5][2505],s2[5][2505]; int flag[5]; int n; int mark[N][N],mark1[N][N]; str原创 2013-10-10 19:40:13 · 493 阅读 · 0 评论 -
hdu 3040 Happy Girls(模拟)
刚开始用字典树写死活就是过不去。后来模拟的G++提交能AC,C++提交就wa。 #include #include #include #define N 50005 struct node { int x; __int64 tt; int id; }a[N],b[N]; int mark[15]; int fun(char *s) { int a,b,c; sscanf(s,"%d:%原创 2013-08-18 05:53:50 · 610 阅读 · 0 评论 -
hdu 1998 奇数阶魔方(找规律+模拟)
应该不算太水吧。 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 对于上面的数据,根据题目中的提示,很容易就看到对角线上的数字是11、12、13、14、15。其他的数据,比如说2,从2往右上查就是2、3、4、5、1。描述起来好原创 2013-07-03 21:41:57 · 1089 阅读 · 0 评论 -
[hackerrank]Fibonacci Modified
题目链接:Fibonacci Modified 题意:就是一个斐波那契变形的数列。麻烦的是结果可能非常大(可能超过十万位?),所以必须在空间和时间上都做一些优化。 #include #include #define N 40005 #define mod 10000 void translate(char *s,int a[],int *a_ln) { memset(a,0,N*siz原创 2016-09-21 13:39:06 · 350 阅读 · 0 评论