#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<algorithm>#include<string>#include<map>#include<set>#include<iostream>#include<vector>#include<queue>using namespace std;#define sz(v) ((int)(v).size())#define rep(i, n) for (int i = 0; i < (n); ++i)#define repf(i, a, b) for (int i = (a); i <= (b); ++i)#define repd(i, a, b) for (int i = (a); i >= (b); --i)#define clr(x) memset(x,0,sizeof(x))#define clrs( x , y ) memset(x,y,sizeof(x))typedef long long lint;const int maxint = -1u>>1;const double esp = 1e-8;const int maxn = 10000 + 10;int n, m;vector<int> e[maxn];int v[maxn];void add(int x, int y){ e[x].push_back(y);}int main(){ while(scanf("%d%d", &n, &m) == 2){ repf(i, 1, n) e[i].clear(); rep(i, m){ int x, y; scanf("%d%d", &x, &y); if(x > y) swap(x, y); add(y, x); } add(n, 1); repf(i, 1, n){ sort(e[i].begin(), e[i].end()); reverse(e[i].begin(), e[i].end()); } memset(v, 0, sizeof(v)); int ans = 0; repf(i, 1, n){ v[i] = v[i - 1] + 1; rep(k, sz(e[i])){ int j = e[i][k]; ans = max(ans, v[i] - v[j] + 1); v[i] = v[j] + 1; } } printf("%dn", ans); } return 0;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)