2302021-03-05 10:49:52mraronKaktuszgráfcpp14Accepted 50/502ms2400 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

int n,m;
vector<pair<int,int>> adj[1001];
int lvl[1001], st[1001];
int ans=0;
void dfs(int x, int pr=-1) {
	st[x]=1;
	for(auto i:adj[x]) {
		if(pr==i.yy) continue ;
		if(st[i.xx]) {
			ans=max(ans, lvl[x]-lvl[i.xx]+1);
		}else {
			lvl[i.xx]=lvl[x]+1;
			dfs(i.xx, i.yy);
		}
	}
}

int main() {
	IO;
	cin>>n>>m;
	for(int i=0;i<m;++i) {
		int x,y;
		cin>>x>>y;
		adj[x].push_back({y,i});
		adj[y].push_back({x,i});
	}
	dfs(1);
	cout<<ans<<"\n";
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1848 KiB
2Accepted0/01ms2032 KiB
3Accepted2/21ms1980 KiB
4Accepted2/22ms2000 KiB
5Accepted2/21ms2008 KiB
6Accepted2/22ms2016 KiB
7Accepted2/21ms2052 KiB
8Accepted2/21ms2036 KiB
9Accepted2/21ms2048 KiB
10Accepted2/21ms2056 KiB
11Accepted2/22ms2084 KiB
12Accepted2/21ms2088 KiB
13Accepted2/21ms2096 KiB
14Accepted2/21ms2168 KiB
15Accepted2/22ms2124 KiB
16Accepted2/22ms2136 KiB
17Accepted2/22ms2152 KiB
18Accepted2/21ms2168 KiB
19Accepted3/32ms2176 KiB
20Accepted3/32ms2348 KiB
21Accepted3/32ms2380 KiB
22Accepted3/31ms2384 KiB
23Accepted3/31ms2392 KiB
24Accepted3/32ms2400 KiB