摘要:
dilworth定理应用#include <stdio.h>#include <algorithm>using namespace std;int a,b,v[20000];struct node{ int w,h;}m[20000];bool cmp(node a,node b){ if(a.w==b.w) return a.h>b.h; else return a.w<b.w;}int f(){ int cnt=0; for(int i=0;i<b;++i) if(!v[i]) { v[i]=1; ... 阅读全文
摘要:
贪心,这里提一下dilworth定理很厉害(http://www.lxlsosi.tk/2011/05/26/%E5%81%8F%E5%BA%8F%E9%9B%86-dilworth-%E5%AE%9A%E7%90%86-poj-1065-3636-1548/)@:因为要消除多算的一次,由dilworth定理将题目从最少不降序列划分转为最长下降子序列,若a.w>b.w则在二分计算时会多算一次,因为实际上两者l是相等的(注意这里下降定义为l,w同时小于),所以通过将小者放在前面,来出去多算的一次。#include <stdio.h>#include <algorithm& 阅读全文