Ugly Window 【acm题】
摘要:话说好久没有碰acm题目了。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。看到Ugly Window这道题目,没有多想,就直接先找到字母的连续长度和连续高度,并统计该字母的总个数,然后用w*h == total+4(四个角落)判断矩形完整不,呜呜,提交后WA了才想到还有可能嵌套的呀呀呀~然后我就打算把矩形的起点和尾点都找出来,然后想到是否还有更好的想法呢?之后我就上网搜了一下,发现了直接找到该字母的连续长度和连续高度后判断中间是否全部为‘.’,周边是否全部为该字母的办法。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。上代码吧~(好久没有单纯的用C语言写过代码了,这
阅读全文
posted @
2013-09-20 19:18
Shirlies
阅读(362)
推荐(0) 编辑
hdu 1509【Windows Message Queue】
摘要:直接暴力,虽然效率很差。。。。。。View Code 1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 5 struct node 6 { 7 char name[100]; 8 int para; 9 int prio;10 int id;11 friend bool operator < (const node& a,const node& b)12 {13 if(a.prio == b.prio)14 return ...
阅读全文
posted @
2012-09-22 21:03
Shirlies
阅读(192)
推荐(0) 编辑
hdu 1873【看病要排队】
摘要:直接模拟。。。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 typedef pair<int,int> pii; 7 8 struct node 9 {10 int id,kb;11 node(){}12 node(int a,int b)13 {14 id = b;15 kb = a;16 }17 friend bool operator <(const n...
阅读全文
posted @
2012-09-21 23:08
Shirlies
阅读(251)
推荐(0) 编辑
hdu 1237【简单计算器】
摘要:简单题,直接模拟,但是还是要仔细点。。。View Code 1 #include <iostream> 2 #include <stack> 3 #include <iomanip> 4 #include <ios> 5 using namespace std; 6 7 int main() 8 { 9 double a;10 while(cin >> a)11 {12 stack<double> Snum;13 stack<char> Sop;14 15 Snum.push(a);16 char ch...
阅读全文
posted @
2012-09-21 22:32
Shirlies
阅读(294)
推荐(0) 编辑
uva 110[The 3n + 1 problem]
摘要:看到《挑战编程》这本书,然后就试试做做上面的题目,之前已经在hdu上面过了这一题了,但是现在看到这一题,我是再想怎么可以运行更少的时间……这里用了一个数组,记录已经计算出的值,结果时间缩短了10倍但是我注释的地方不知道为什么会用问题,如果加上那一段就会RE~_~代码如下: 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 5 int vis[1000000+10]; 6 int get_value(int x) 7 { 8 if(vis[x] != 0) return vis[x];
阅读全文
posted @
2012-08-08 16:56
Shirlies
阅读(275)
推荐(0) 编辑
uva 10761
摘要:用两个数组存储,再排序就OK了,如果有1 2,没有2 1,那么第二个数组排序后肯定没有1 2,那么就NO了~~~View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 struct per 6 { 7 int start,end; 8 }; 9 per p[500010],rp[500010];10 11 bool cmp(per p1,per p2)12 {13 if(p1.start == p2.start)14 return p1.end < p2
阅读全文
posted @
2012-03-15 15:57
Shirlies
阅读(201)
推荐(0) 编辑
hdu 2094
摘要:这一题是参考别人的,但是此题用到了映射,第一次用映射,感觉到了stl的方便之处http://blog.csdn.net/acb0y/article/details/5865561
阅读全文
posted @
2012-03-01 22:33
Shirlies
阅读(172)
推荐(0) 编辑
hdu 3293
摘要:这一题死的很悲剧,就n值问题,起初我还一直以为是排序的cmp出问题了,检查它,却忽略了后面的检查……呜呜~~~~(>_<)~~~~ 竟然wa了那么多次,而且用了那么长时间,如此基础的题目,看来我检查错误的能力还有待改善啊~~~View Code #include <cstdio>#include <cstdlib>#include <string>using namespace std;struct node{ char a1[100]; char b1[100]; char c1[100];}in[1000];int cmp(const voi
阅读全文
posted @
2012-02-28 23:21
Shirlies
阅读(193)
推荐(0) 编辑
hdu acm 2673
摘要:Problem DescriptionAcmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first.The problem is :Give you a sequence of distinct integers, choose
阅读全文
posted @
2012-01-17 21:08
Shirlies
阅读(259)
推荐(0) 编辑
UVa 494
摘要:#include "stdio.h"int main(){int count;char ch;int ok=0;while((ch=getchar())!=EOF){ok=0;count=0;while(ch!='\n'){if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))ok=1;if(ok&&!((ch>='A'&&ch<='Z'
阅读全文
posted @
2012-01-16 13:08
Shirlies
阅读(179)
推荐(0) 编辑
UVa 10055
摘要:最近做的题目可能都会是西班牙Valladolid大学的UVaOJ上面的题目,因为最近看的是Rujia Liu先生的书,他的书上面的题目练习是这个上面的哈这是我在上面做的第一道题目,但是已经开始出现问题啦#include "stdio.h"int main(){long long n,m,t;while(scanf("%lld%lld",&n,&m)==2){if(n>m){t=n;n=m;m=t;}printf("%lld\n",m-n);}return 0;}就是这样写在Microsoft Visual C++
阅读全文
posted @
2012-01-15 20:10
Shirlies
阅读(580)
推荐(0) 编辑
poj2136
摘要:我真的很想在这里好好分析一下这一题啊,首先一看题目给人的感觉就是貌似每行如果后面都是空格就不能输出,但是貌似这样很难,我就先不试这个,看看用矩形可以不,然后我敲出来了,第一次是最后面有空格,错了,嗯嗯,空格有问题,并好好分析了一下题目,发现“shows how many times each letter (but not blanks, digits, or punctuation) appears in the all-upper-case input“,喔,是输入的字符字母的个数(即没有的不用输出打印咯),改了两方面:输出空格,输出字符;但是结果竟然是错的,但是再细细理解,没有错啊,怎么
阅读全文
posted @
2011-12-17 20:17
Shirlies
阅读(570)
推荐(0) 编辑