CORG - Editorial

PROBLEM LINK:

Practice
Contest

Author: Adarsh Kumar Sinha

DIFFICULTY:

Easy

SOLUTION:

Setter's Solution
/*----- || Hare Krishna || -----*/
/*  "WHY DO WE FALL, BRUCE?"  */

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input5.txt","r",stdin);
//    freopen("output5.txt","w",stdout);
        
    t=1;
    
	while(t--){
		
		int n,m,a,b;
		cin >> n;
		cin >> m;
		
		int mat[n+1][n+1];
		memset(mat, 0 ,sizeof(mat));  // pre-setting as 0
		
		while(m--){
			int a,b;
			cin >> a >> b;
			mat[a][b]=1;  // indicating there's a route between a and b
			mat[b][a]=1;  // same
		}
		
		vector<int> rdx(n+1, 0);  // to store how many cities are directly enrouted with current city
		
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				if(mat[i][j]==1 && i!=j){ // not considering self connecting roads as it will not add new city for its spread
					rdx[i]++;
				}
			}
		}
		
		int ans=0;
		
		for(int i=1; i<=n; i++){
			int cities= 1+rdx[i]; // cities covered if the curent city is chosen as the hot-spot
			ans = max(ans, cities);
		}
		cout << ans << endl;
	}  
}