2011年4月16日

poj 3670

摘要: 递增或递减序列。代码:#include<iostream>#include<fstream>using namespace std;int a[30001];int n;int b[30001];int c[30001];int find(int s,int value){ int i=0,k; while(i<=s) { k=(i+s)>>1; if(b[k]<value) s=k-1; else i=k+1; } return s;}int find1(int s,int value){ int i=0,k; while(i<=s) { 阅读全文

posted @ 2011-04-16 20:44 宇宙吾心 阅读(314) 评论(0) 推荐(0)

poj 1065

摘要: 偏序定理。同3636代码:#include<iostream>#include<fstream>using namespace std;struct e{ int w,h;};e a[5001];int n;int b[5001];int cmp(const void *a,const void *b){ if(((e *)b)->w-((e*)a)->w!=0) return ((e *)a)->w-((e*)b)->w; else return ((e*)a)->h-((e*)b)->h;}int find(int s,int v 阅读全文

posted @ 2011-04-16 20:28 宇宙吾心 阅读(178) 评论(0) 推荐(0)

poj 3636

摘要: 偏序定理。注意1. 偏序定理。2. 最长递减子序列的nlogn算法。3.qosrt是不稳定排序。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int w,h;};e a[20001];int n;int b[20001];int cmp(const void *a,const void *b){ if(((e *)b)->w-((e*)a)->w!=0) return ((e *)a)->w-((e*)b)->w; else return ((e*)b)-& 阅读全文

posted @ 2011-04-16 19:48 宇宙吾心 阅读(393) 评论(0) 推荐(0)

poj 2533

摘要: 水题。o(n^2)也可以。代码:#include<iostream>#include<fstream>using namespace std;int a[10001];int b[10001];int n;void read(){// ifstream cin("in.txt"); int i,j,k; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) b[i]=1; for(i=1;i<=n;i++) for(j=i-1;j>=0;j--) 阅读全文

posted @ 2011-04-16 18:19 宇宙吾心 阅读(212) 评论(0) 推荐(0)

导航