You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
948 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e6 + 10;
int n, m;
int ans, f[N];
PII a[N];
int al;
// 本代码未AC8/10通过原因未知
int main() {
#ifndef ONLINE_JUDGE
freopen("2549.in", "r", stdin);
#endif
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
char x;
cin >> x;
if (x == '1') a[al++] = {i, j};
}
// 似乎不需要进行排序,因为上面就是按顺序输入的节点
sort(a, a + al);
// LIS
for (int i = 0; i < al; i++) f[i] = 1; // DP数据初始化
for (int i = 0; i < al; i++)
for (int j = 0; j < i; j++)
if (a[j].y > a[i].y) f[i] = max(f[i], f[j] + 1);
// Dilworth
for (int i = 0; i < al; i++) ans = max(ans, f[i]);
printf("%d\n", ans);
return 0;
}