1 #include<bits/stdc++.h> 2 3 using namespace std; 4 5 vector<int> ve[1000005]; 6 int a[1000005]; 7 8 struct node 9 { 10 int id; 11 int num; 12 int jieguo; 13 }s[1000005]; 14 15 bool cmp(node a, node b) 16 { 17 return a.num < b.num; 18 } 19 20 int main() 21 { 22 int n, m, pos, u, v, maxx; 23 int anss; 24 25 scanf("%d %d", &n, &m); 26 for(int i=0;i<n;i++) 27 { 28 s[i].id = i; 29 } 30 31 while(m--) 32 { 33 scanf("%d %d", &u, &v); 34 s[u].num++; 35 s[v].num++; 36 ve[u].push_back(v); 37 ve[v].push_back(u); 38 } 39 40 sort(s, s+n, cmp); 41 for(int i=0;i<n;i++) 42 { 43 a[s[i].id] = i; 44 } 45 46 anss = 1; 47 for(int i=0;i<n;i++) 48 { 49 maxx = 1; 50 for(auto it:ve[s[i].id]) 51 { 52 pos = it; 53 if(s[a[pos]].num < s[i].num) 54 maxx = max(s[a[pos]].jieguo + 1, maxx); 55 } 56 s[i].jieguo = maxx; 57 anss = max(anss, s[i].jieguo); 58 } 59 60 printf("%d ", anss); 61 return 0; 62 }