【BZOJ 3997】[TJOI2015] 组合数学

相关链接

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3997
神犇题解:http://blog.csdn.net/popoqqq/article/details/45171469

解题报告

这题又™是结论题
需要用到的结论:

Dilworth定理:DAG的最小链覆盖=最大点独立集

类似的结论还有:

最大团=补图上的最小点覆盖的补集
最大反链的大小=最小链划分
最大链的大小=最小反链划分

知道结论之后,实际上就是让你求一些点,相互不能到达,且点权和最大
这样的话,从左下到右上搞一个DP就可以了!

Code

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 1000+9;

int n,m,val[N][N],f[N][N],g[N]; 

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	for (int T=read();T;T--) {
		memset(f,0,sizeof(f));
		memset(g,0,sizeof(g));
		m = read(); n = read();
		for (int j=1;j<=m;j++) {
			for (int i=1;i<=n;i++) {
				val[i][j] = read();
			}
		}
		for (int i=1;i<=n;i++) {
			for (int j=m,cur=0;j;j--) {
				f[i][j] = cur + val[i][j];
				cur = max(cur, g[j]);
				g[j] = max(g[j], f[i][j]);
			}
		}
		int vout = 0;
		for (int i=1;i<=m;i++) 
			vout = max(vout, g[i]);
		printf("%d\n",vout);
	}
	return 0;
}

14 thoughts to “【BZOJ 3997】[TJOI2015] 组合数学”

  1. Thank you for another informative website. Where else could I get that kind of info written in such a perfect way? I have a project that I am just now working on, and I have been on the look out for such info.

  2. 942148 869262This post contains excellent original thinking. The informational content material here proves that things arent so black and white. I feel smarter from just reading this. 598839

  3. 343580 510280We stumbled over here coming from a different internet page and thought I may possibly check issues out. I like what I see so now im following you. Appear forward to exploring your internet page however again. 197358

  4. 181288 573483Greatest fighter toasts ought to entertain and supply prize on your couples. Initially audio system next to obnoxious crowd would be wise to understand 1 certain gold colored strategy as to public speaking, which is individual interests self. very best man jokes 641506

  5. 867674 387686Hi there, just became aware of your blog by way of Google, and found that its genuinely informative. Im gonna watch out for brussels. Ill be grateful should you continue this in future. Numerous men and women is going to be benefited from your writing. Cheers! 401771

Leave a Reply

Your email address will not be published. Required fields are marked *