摘要: 效率太低了,反思~~~~1:题意理解错误where xxx is the number of relations processed at the time either a sorted sequence is determined or an inconsistency is found, whichever comes first, and yyy...y is the sorted, ascending sequence.明明没说是按它列的顺序求解--关系的数量,2:对环的处理上没有搞好#include<stdio.h>#include<string.h>#de 阅读全文
posted @ 2012-03-22 01:32 skyming 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 终于搞定了第一网络流的题~~看了好久啊才理解题意: 求排水沟的最大流量,最大流的模版题,EK算法 若没听说过网络流,直接pass 吧.用g++提交 加上 string.h#include<iostream>#include<cstdio>#include<queue>using namespace std;const int N =210;const int inf =0x7fffffff;int map[N][N],path[N],flow[N];int start,end,m,n;queue<int> q;int bfs(){ while(! 阅读全文
posted @ 2012-03-21 02:02 skyming 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 好纠结啊,方向转晕了~~~~~先贴个半山寨的代码#include <cstdio>#include<string.h>#define MAX 45 struct node{ int x,y;}stack[2000]; int flag[MAX][MAX];char map[MAX][MAX];int dirl[4][2]={{-1,0},{0,1},{1,0},{0,-1}}; // Left firstint dirr[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; //Right firstint w,h, d1,d2;int start[2] 阅读全文
posted @ 2012-03-18 13:00 skyming 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 题意: 牛逃跑了,主人用最短的时间追到牛(在直线上) 很裸的bfs ,郁闷啊忘了判断重复了,RE ,WA !#include<stdio.h>#define N 100005int n,k;int stack[N],vis[N];int main(){ scanf("%d%d",&n,&k); int di=0,top=1,first=0,last=1; int sum=0;stack[0]=n,vis[n]=1; while(di!=top) { last--; int num=stack[di++]; if(num!=... 阅读全文
posted @ 2012-03-09 00:39 skyming 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 题意分析: 对机器人的移动作可能结果; 1:超出矩阵范围 2:和其他机器人相撞 3:OK 对于每次命令进行模拟和判断,自己写的太乱了代码 200+ ; 第一次做的忘了对相撞的加以判断,WA ,看了discussion 里的数据 才找到错误;细心!!!#include<stdio.h>#include<string.h>int map[105][105];struct node{ int x,y; char dir;}grah[105];int main(){ int t;scanf("%d",&t); while(t--) { int x,y 阅读全文
posted @ 2012-03-08 20:52 skyming 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 题意: 先输入右括号前左括号的数量 输出每个括号所含括号的数量(从左至右)思路: 由于以前模拟题留下太大的阴影,比较凌乱:没想到今天 模拟1Y 虽然题简单点,就是用-1 1 模拟 括号 ,向前搜索即可#include<stdio.h>int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int flag[50],top=0; int first,m; scanf("%d",&m);first=m; w... 阅读全文
posted @ 2012-03-06 21:53 skyming 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 题意: 检测输入字符串和库里的字符串是否相符 相符按要求输出即可,若不符;分三种情况讨论 1;字符串长度相等 处理很简单,掠过 2;字符串不等时,分别设两个指针,从前向后,从后向前移动判断即可 注意判断边界条件 top1>di !!!#include<stdio.h>#include<math.h>#include<string.h>struct node{ char str[20];}map[10005];int main(){ int top=0; while(gets(map[top++].str)&&map[top-1].str 阅读全文
posted @ 2012-03-05 20:24 skyming 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 对于并查集: 很多次都是迷迷糊糊,尤其是对并查集的优化:1.路径压缩 2.按秩合并对此个人整理了一下:对于最基本的并查集建议看看:百度百科: http://baike.baidu.com/view/521705.htm以例题的形式分析,并用算法描述了博客园: 对于有点基础的可以参考下,清晰明了http://www.cnblogs.com/cherish_yimi/archive/2009/10/11/1580839.html对于第二个优化按秩合并的部分处理有点异议:if(rank[x] < rank[y]) { num[x]=y; } else if(rank[x]> rank[y 阅读全文
posted @ 2012-03-02 19:53 skyming 阅读(1422) 评论(0) 推荐(2) 编辑
摘要: 维基百科:动画很帅 ,很简明说明归并排序http://en.wikipedia.org/wiki/Merge_sort 一看这题 7000MS ,果断 暴力, 结果TLE 。。。。 然后用归并写了一个,WA ,弱爆了,后来看了下解题报告, 判断条件考虑不全面。。。。。#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;const int N=500005;__int64 sum,n;int num[N],stack[N];void mergesort(int lo 阅读全文
posted @ 2012-03-01 12:29 skyming 阅读(949) 评论(0) 推荐(0) 编辑
摘要: 由于本周的任务太多,没打算做这次比赛。但pc坚持做,我也屈服了。。。总结一下总体上: 审题: 主要是英语+推题;————>加强; 思路: 代码没有太长的,太繁杂的,只有思想对,基本都AC。 算法都属于基础算法行列,由于某些算法理解不足。 导致做题的思路偏窄。~~~~一直WA~ T_T A: 简单的比较~~ B: 调一个排序就解决了~~ C: 这个题挺好~~~用贪心做的一直WA~~ 后来看了别人的代码,贪心的也有AC的,但是贪心做的我看到的好几个都不对; 贪的角度是把每个隐藏的一对字母遍历一遍,方向挺好;... 阅读全文
posted @ 2012-02-25 15:32 skyming 阅读(288) 评论(0) 推荐(0) 编辑