- 博客(19)
- 资源 (1)
- 收藏
- 关注
原创 zoj3166 Lazy Tourist//floyd求两点间最短路
#include#include#include#includeusing namespace std;#define inf 100005#define N 105int g[N][N],dist[N][N];int n,c;int cs[N];int cmp(const void *a,const void *b){ return *(int *)a>*(int *)b
2012-03-20 19:47:44 581
原创 zoj 3197 Google Book//最小区间覆盖
最悲哀的,莫过于死活不过...#include#include#include#includeusing namespace std;#define N 5005class node{public: int left,right;};node st[N];int n;int cmp(const void *a,const void *b){ node *c =(n
2012-03-19 13:57:05 759
原创 ZOJ 3107 Counting Squares//计算几何
题意:按指令画多边形,求出里面有多少个正方形。思路:求出面积。注意:需判断多边形的走向,利用叉积的正负个数。#include#include#include#includeint dir[][4]={{0,1},{0,-1},{-1,0},{1,0}};int f(char ch ){ if(ch=='U') return 0; else if(ch=='D') retur
2012-03-19 13:08:56 535
原创 zoj3123 Subsequence//最短序列和
毫无优化时,TLE, 加入二分优化,时间为50ms.强大的二分AC代码:#include#include#includeusing namespace std;#define N 100005int a[N];int main(){ int t; cin>>t; while(t--) { int n,s; int su=0; scanf("%d%d",&
2012-03-18 15:58:13 642
原创 hdu 1176免费馅饼 //dp
#include#include#includeusing namespace std;#define ma(x,y) ((x>y?x:y))int dp[11][100005],time[11][100005];int main(){ int n; while(scanf("%d",&n)!=EOF&&n) { memset(dp,0,sizeof(dp)); mem
2012-03-18 12:48:01 422
原创 hdu1466 计算直线的交点数//dp+set
#include#include#includeusing namespace std;class node{public: sett;};node st[21];int main(){ st[1].t .insert (0); st[2].t .insert (0); st[2].t .insert (1); st[3].t .insert (0); st[3].
2012-03-17 20:25:08 696
原创 zoj 3513 Human or Pig//
题意难读懂。理解这句:猪随意跳,人可以选择。要确保跳河里的时候,是猪就行。#include#includeusing namespace std;int n,m;char s[51000];bool find(int x,int y,int cul){ int k=1,temp; if(x>y) { int tempx =x-k*y; while(tempx>=0)
2012-03-16 13:38:50 520
原创 zoj3551 Bloodsucker//概率&dp
参考:http://raya.blogcn.com/articles/zoj-3551.html#include#includeusing namespace std;double dp[100005];int main(){ int t,n; double p; scanf("%d",&t); while(t--) { scanf("%d%lf",&n,&p);
2012-03-15 19:39:45 632
原创 zoj3321Circle//回路判断
题目提示只有一条回路。思路:并查集+出入度检测。#include#include#include#includeusing namespace std;int n,m;int f[20],rank[20],vis[20];void solve(int a[]){ for(int i=1;i<=n;i++) if(a[i]!=0&&a[i]!=2) { cout<
2012-03-11 19:13:48 617
原创 zoj 3230Solving the Problems//优先队列
#include#include#include#include#includeusing namespace std;#define N 100005class node{public: int a,b;};bool operator< (const node &a,const node &b){ if(a.b<b.b ) return true; return f
2012-03-10 20:21:08 527
原创 zoj 3204 Connect them//最小生成树
kru算法。#include#include#include#includeusing namespace std;int n,g[111][111];class node{public: int u,v,len;};int len;node edge[110000];int pre[111];void input(){ for(int i=1;i<=n;i
2012-03-10 19:39:13 566
原创 观《迫在眉捷》有感
心情实在是差,so terrible.在风行上挑了部电影看。 影片刚开始,就描述了美国萧条时期,约翰因无钱还房贷,车子被拖了。当然,这不是最糟糕的。在一场棒球赛上,约翰的儿子的心脏出了问题。 这时候,如果想要儿子活下来,约翰需要约7万美元。It is a big trouble for him。After having tried his best, he st
2012-03-10 01:00:34 2441
原创 zoj3519 Who is the Smartest Man//贪心
#include#include#include#includeusing namespace std;int p[506];int cc,n;int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int main(){ while(scanf("%d%d",&n,&cc)!=EOF) {
2012-03-09 19:00:18 535
原创 poj 3908 Quick answer//并查集
并查集的删除操作:建立映射id[n]=n,忽视删除的点n,当n需要再入集合时,id[n]=n+1。#include#include#includeusing namespace std;#define N 2000000int id[10005],p[N];int n,num;void init(){ for(int i=1;i<=n;i++) p[i]=i,id[i]=i
2012-03-08 15:55:19 719
原创 poj 1703 Find them, Catch them //并查集
再一次做此题,温习并查集。rank[x]记录的是x与father[x]的关系,值为0表示与根节点一致,1表示不同。初始化时,都一致,值为0。ps:代码敲得比第一次的搓...#include#include#includeusing namespace std;#define N 100005int father[N],rank[N];int n,m;void init
2012-03-08 15:26:06 326
原创 zoj2833 Friendship //并查集
简单并查集。ps:输出超恶心,用队列搞...#include#include#include#includeusing namespace std;#define N 100005int n,m;int rank[N],father[N];class node{public: queueq; int num;};node p[100];void set(int
2012-03-06 22:37:07 661
原创 poj 2387 Til the Cows Come Home//最短路径
求1到N的最短路径。用的spfa算法,注意重边问题。#include#include#includeusing namespace std;const int maxn = 1007;const int maxcost = 99999999;int n,t;int g[maxn][maxn],dist[maxn],vis[maxn];int queue[maxn*8],fron
2012-03-02 15:20:41 403
原创 zoj 1711 Sum It Up //深搜
居然没超时 ... ps:index 是关键字么 ...#include#include#include#includeusing namespace std;int t,n,flag,ll;int a[14],vis[14];char pr[1000][100];//int f[15]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096
2012-03-01 15:20:07 1141
创建学生信息管理系统
2010-12-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人