Submission #972131

# Submission time Handle Problem Language Result Execution time Memory
972131 2024-04-30T06:46:10 Z Circling Cijanobakterije (COCI21_cijanobakterije) C++17
70 / 70
29 ms 13404 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


bool visited[100001];
vector<vector<int>> graph;


pair<int, int> maxpath(int node){
    visited[node] = true;
    int m1 = 0, m2 = 0;
    pair<int, int> ans = {1, 1}, neighans;
    for (int neigh: graph[node]){
        if (visited[neigh]) continue;
        neighans = maxpath(neigh);
        ans.first = max(neighans.first, ans.first);
        if (m1 < neighans.second){
            m2 = m1;
            m1 = neighans.second;
        } else m2 = max(m2, neighans.second);
    }
    ans.first = max(ans.first, m1 + m2 + 1);
    ans.second = m1 + 1;
    return ans;
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, a, b, ans = 0;
    cin >> n >> m;
    graph.resize(n + 1);
    while (m--){
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) visited[i] = false;
    for (int i = 1; i <= n; i++) if (!visited[i]) ans += maxpath(i).first;
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 12 ms 3676 KB Output is correct
4 Correct 15 ms 4952 KB Output is correct
5 Correct 19 ms 5932 KB Output is correct
6 Correct 24 ms 7260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 13404 KB Output is correct
2 Correct 2 ms 1116 KB Output is correct
3 Correct 4 ms 2140 KB Output is correct
4 Correct 6 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 1372 KB Output is correct
6 Correct 5 ms 2360 KB Output is correct
7 Correct 7 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 12 ms 3676 KB Output is correct
4 Correct 15 ms 4952 KB Output is correct
5 Correct 19 ms 5932 KB Output is correct
6 Correct 24 ms 7260 KB Output is correct
7 Correct 22 ms 13404 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 4 ms 2140 KB Output is correct
10 Correct 6 ms 2908 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 3 ms 1372 KB Output is correct
16 Correct 5 ms 2360 KB Output is correct
17 Correct 7 ms 3416 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 25 ms 7260 KB Output is correct
30 Correct 6 ms 3928 KB Output is correct
31 Correct 16 ms 6748 KB Output is correct
32 Correct 11 ms 4768 KB Output is correct
33 Correct 21 ms 7000 KB Output is correct
34 Correct 14 ms 5468 KB Output is correct
35 Correct 18 ms 6748 KB Output is correct
36 Correct 18 ms 6004 KB Output is correct
37 Correct 29 ms 6972 KB Output is correct
38 Correct 25 ms 6476 KB Output is correct
39 Correct 19 ms 6992 KB Output is correct