摘要: /*题目: XML有缩进,并且会在之前的缩进基础上缩进几个空格,现在问缩进k个空格的标签分析: 模拟队列,及时更新空格即可*/#include <iostream>#include <cstdio>#include <cstring>#include <vector>using namespace std;const int X = 20005;int n,k;char s[105];char p[105];vector<int> vec[X];struct node{ char s[105]; int num;}q[X],ans[X 阅读全文
posted @ 2012-07-25 12:48 yejinru 阅读(201) 评论(0) 推荐(0) 编辑
摘要: /*题目: 模拟排队的实现,但是若是有同伙的话,这些家伙就会插队,排到他们的同伙的后面,要不就乖乖地排到队伍的后面。现在给出朋友关系以及进队出队的顺序,问你当出队时是谁在出队分析: 利用优先队列,重载小于号,使得优先级最大的先出队,优先级的定义如下:当前面有同伙时,按照前面的同伙的优先级来插入,若没有的话,就按照现在的优先插入。当优先级相同时,按照先进队的优先级越大就越大。*/#include <iostream>#include <cstdio>#include <queue>#include <cstring>using namespace 阅读全文
posted @ 2012-07-25 12:47 yejinru 阅读(232) 评论(0) 推荐(0) 编辑
摘要: /*题目: 每一天都只能每一种鱼,并且买了这种鱼后,在以后每周的该天都得买那种鱼。 另外如果某一天没买鱼的话,就不能在以后买鱼了(已被饿死。。。)。现在 给出n天每一种鱼的价格,并且给出你拥有的价钱,问你什么时候不能再买鱼了分析: map[i,j]表示从第一天开始买了j种鱼到i天时所用的总价钱。然后从后面开始枚举 答案,枚举一周内每天所使用的价钱总和若不大于你拥有的金钱时就输出答案*/#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int X = 阅读全文
posted @ 2012-07-25 12:46 yejinru 阅读(164) 评论(0) 推荐(0) 编辑
摘要: /*用结构体数组模拟栈,结构体中保存当前min与max的值*/#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int X = 65537;int n,top;struct node{ int max,min;}stack[X];int main(){ freopen("sum.in","r",stdin); char s[10]; int x; int ncase = 0; while(cin>> 阅读全文
posted @ 2012-07-25 12:44 yejinru 阅读(202) 评论(0) 推荐(0) 编辑
摘要: /*题目: 模拟输出数字时钟分析: 先把答案都只为空格,然后枚举每一个数字,在相应的答案数组上做修改,这样的话,只需 做出来了数字8,其他的都可以实现了。代码很简练,只有100来行*/#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int X = 205;char map[X][X],s[X];int n;int main(){ freopen("sum.in","r",stdin); freopen(&qu 阅读全文
posted @ 2012-07-25 12:42 yejinru 阅读(187) 评论(0) 推荐(0) 编辑