Submission #799199

# Submission time Handle Problem Language Result Execution time Memory
799199 2023-07-31T10:42:37 Z tlnk07 Cijanobakterije (COCI21_cijanobakterije) C++17
70 / 70
68 ms 13220 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

long long n, m, x, y, dis[100001], ans = 0;
vector<int> vec[100001];
bool check[100001];
pair<int, int> maxi;

void dfs(int x, int p, int h)
{
	check[x] = true;
	for(int c : vec[x])	if(c != p)	dfs(c, x, h + 1);
	if(maxi.first < h)	maxi = {h, x};
}

signed main()
{
	
	cin >> n >> m;
	while(m--)
	{
		cin >> x >> y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	for(int i = 1; i <= n; ++i)
	{
		if(!check[i])
		{
			check[i] = true;
			maxi = {-1, -1};
			dfs(i, 0, 1);
			dfs(maxi.second, 0, 1);
			ans += maxi.first;
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3440 KB Output is correct
2 Correct 19 ms 4444 KB Output is correct
3 Correct 28 ms 5016 KB Output is correct
4 Correct 41 ms 5964 KB Output is correct
5 Correct 45 ms 6792 KB Output is correct
6 Correct 68 ms 7744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 13220 KB Output is correct
2 Correct 7 ms 3156 KB Output is correct
3 Correct 10 ms 3568 KB Output is correct
4 Correct 14 ms 4104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 7 ms 3312 KB Output is correct
6 Correct 12 ms 3924 KB Output is correct
7 Correct 17 ms 4732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2724 KB Output is correct
3 Correct 1 ms 2660 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3440 KB Output is correct
2 Correct 19 ms 4444 KB Output is correct
3 Correct 28 ms 5016 KB Output is correct
4 Correct 41 ms 5964 KB Output is correct
5 Correct 45 ms 6792 KB Output is correct
6 Correct 68 ms 7744 KB Output is correct
7 Correct 54 ms 13220 KB Output is correct
8 Correct 7 ms 3156 KB Output is correct
9 Correct 10 ms 3568 KB Output is correct
10 Correct 14 ms 4104 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 7 ms 3312 KB Output is correct
16 Correct 12 ms 3924 KB Output is correct
17 Correct 17 ms 4732 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2724 KB Output is correct
20 Correct 1 ms 2660 KB Output is correct
21 Correct 2 ms 2640 KB Output is correct
22 Correct 2 ms 2772 KB Output is correct
23 Correct 2 ms 2660 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 53 ms 7616 KB Output is correct
30 Correct 11 ms 3756 KB Output is correct
31 Correct 36 ms 6624 KB Output is correct
32 Correct 21 ms 4616 KB Output is correct
33 Correct 48 ms 7248 KB Output is correct
34 Correct 31 ms 5324 KB Output is correct
35 Correct 41 ms 6800 KB Output is correct
36 Correct 39 ms 6104 KB Output is correct
37 Correct 47 ms 7228 KB Output is correct
38 Correct 60 ms 6732 KB Output is correct
39 Correct 43 ms 6896 KB Output is correct