
搜索
文章平均质量分 69
xxx_bug
这个作者很懒,什么都没留下…
展开
-
ZOJ Problem Set - 1709 Oil Deposits
一开始暴力,WA 了很多次,后来发现一大堆的漏洞,修补之后发现不行。才想到搜索之,所以改用BFS。A了!但是却耗费一大堆时间。BFS的思路是一轮一轮的找同一个油田的洞口,记录总共找了多少轮就行了!总结: 这种图的最好一开始就先用搜索试试!DFS或BFS!暴力实在坑爹! 发原创 2011-10-04 20:33:57 · 428 阅读 · 0 评论 -
ZOJ Problem Set - 1060 Sorting It All Out
这题终于过了~~搞了很久的题啊~~N久啊~~过了真他妈的爽啊~~整理下思路~1、边输入边判断是否矛盾,这是我今天搞的最久的操作。一开始的做法是输入A有的人理解成判断是否存在回路的方法也可以,一开始我的思路就是这样的,然后用dfs()判断一下,发现有些数据会坑爹地循环。也可以用传递闭包的算法做。2、用数组来记录第几个操作。要拓扑排序的话,如果每次的输入都排一次那就太浪费时间,有可原创 2012-05-06 18:35:41 · 487 阅读 · 0 评论 -
CF 128A Statues
思维从未深入的思考!这道题的突破点就是,只要M能存在超过8步,那么就能成功到达!所以DFS9个位置即可!而S一步下落一次,那么走到step,那么S也就下降了step,所以全部状态就可知了! 反省了一下自己的思考,一开始就在想能不能BFS所有的状态,但是很明显这种方法的结果就是果断地爆了内存。也有可能TLE。然后我就想能不能找到规律,最后还是想不到,我还是没有很好的抓住问题的突破点,然后原创 2012-04-12 19:46:02 · 585 阅读 · 0 评论 -
CF 4D Mysterious Present
dfs题!!用Dp!可是就这么简单的思路,我偏偏绕远路,用LCS来DP求,被无情的MLE!#include#includeusing namespace std;int dfs(int);int w[5001],h[5001],d[5001],p[5001],n;main(){ cin>>n; for(int i=0;i<=n;i++) cin>>w[i]>>h[i]; m原创 2012-03-30 19:14:02 · 510 阅读 · 0 评论 -
hdu 2199 Can you solve this equation?
解方程:#include #include #define eps 1e-8using namespace std;double aim;double bs(){ double l = 0,r = 100,m; while(l < r) { //cout<<m<<endl; m = (l+r) / 2; if(原创 2012-03-09 00:39:11 · 532 阅读 · 0 评论 -
ZOJ Problem Set - 1005 Jugs
简单BFS#include #include using namespace std;struct Node{ int a,b; string str;};queue qt;bool cot[1001][1001];int main(){ int aV,bV,aimV,i,j; Node tmp1,tmp,sta; while(原创 2012-02-23 14:56:41 · 556 阅读 · 0 评论 -
ZOJ Problem Set - 1002 Fire Net
以前花了无数时间在这题上,今天终于弄懂了。这题的数据量很小,直接暴力就可。每个点有两种情况:放或不放。 用 0 ,1表示。遍历 + 判断。#include using namespace std;int cot[4][4],N,ans,flag,sum;bool Jud(int x,int y){ int i; if(cot[x][y] ==原创 2012-02-22 20:16:21 · 1006 阅读 · 1 评论 -
ZOJ Problem Set - 1940 Dungeon Master
BFS简单的!!!!#include #include #include #include using namespace std;struct Node{ int l; int r; int c; int t;};char ch[31][31][31];queue q;int main(){ int l,r,c,i,j,k,x原创 2011-10-19 20:45:15 · 693 阅读 · 0 评论 -
ZOJ Problem Set - 1004 Anagrams by Stack
/*以下是一段很烂很差的代码,简单的DFS 却 坑死人。对栈的处理不够熟悉。比起班上某位女牛的代码 相差太大了。回溯你妹的!回溯的东西都是他妈的参数。用数来记录比用一开始做的string做的容易理解的多。对某些恶心的片段那也是为了AC被迫写的!龙哥 我对自己无语了!原创 2011-10-18 16:30:22 · 606 阅读 · 0 评论 -
龙哥牛b代码!ZOJ Problem Set - 1649 Rescue
/*zoj_1649 搜索毫无疑问是bfs啦。。本题x的出现是难点。每次过x的时候step是要+2,但是+2以后它应该放到队列的哪个位置呢?我一开始的想法是先用一个临时队列存起来,在下一轮的时候让临时队列里的东西进主队列。。然后一直wa。。最后才明白,每一轮只消耗一转载 2011-10-08 22:33:09 · 665 阅读 · 0 评论 -
ZOJ Problem Set - 2922 Bombs
一道简单题,注意不要SE,就是数组访问越界。从后面一直搜索下来,按纵列。两个函数就可以搞定!水了!#include using namespace std;int map[1001][1001],m[1001][1001];void setx(int x,原创 2011-10-08 22:22:45 · 626 阅读 · 0 评论 -
ZOJ Problem Set - 3607 Lazier Salesgirl
枚举每段距离!#include #include #include #include #include #include #include #include #include #include using namespace std;int main(){ int p[1010],t[1010],n,i,j,ti,q,k,dis[1010]; doub原创 2012-04-20 20:41:03 · 833 阅读 · 0 评论