Submission #557373

# Submission time Handle Problem Language Result Execution time Memory
557373 2022-05-05T08:34:07 Z new_acc Cijanobakterije (COCI21_cijanobakterije) C++14
70 / 70
55 ms 31544 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N],maxi,g;
bitset<N>vis;
vi graf[N];
void dfs(int v,int o,int gl){
    vis[v]=1;
    if(gl>=maxi) maxi=gl,g=v;
    for(auto u:graf[v]){
        if(u==o) continue;
        dfs(u,v,gl+1);
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    for(int a,b,i=1;i<=m;i++){
        cin>>a>>b;
        graf[a].push_back(b),graf[b].push_back(a);
    }
    int res=0;
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        dfs(i,i,0);
        maxi=0;
        dfs(g,g,0);
        res+=maxi+1;
        maxi=0;
    }
    cout<<res<<"\n";
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 24320 KB Output is correct
2 Correct 25 ms 24856 KB Output is correct
3 Correct 32 ms 25400 KB Output is correct
4 Correct 48 ms 25964 KB Output is correct
5 Correct 48 ms 26464 KB Output is correct
6 Correct 48 ms 26960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 31544 KB Output is correct
2 Correct 15 ms 24332 KB Output is correct
3 Correct 21 ms 24792 KB Output is correct
4 Correct 24 ms 25292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23888 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23744 KB Output is correct
5 Correct 16 ms 24344 KB Output is correct
6 Correct 19 ms 25000 KB Output is correct
7 Correct 22 ms 25560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23796 KB Output is correct
3 Correct 16 ms 23752 KB Output is correct
4 Correct 15 ms 23708 KB Output is correct
5 Correct 17 ms 23816 KB Output is correct
6 Correct 13 ms 23812 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 13 ms 23776 KB Output is correct
9 Correct 12 ms 23820 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 15 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 24320 KB Output is correct
2 Correct 25 ms 24856 KB Output is correct
3 Correct 32 ms 25400 KB Output is correct
4 Correct 48 ms 25964 KB Output is correct
5 Correct 48 ms 26464 KB Output is correct
6 Correct 48 ms 26960 KB Output is correct
7 Correct 39 ms 31544 KB Output is correct
8 Correct 15 ms 24332 KB Output is correct
9 Correct 21 ms 24792 KB Output is correct
10 Correct 24 ms 25292 KB Output is correct
11 Correct 12 ms 23888 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 12 ms 23764 KB Output is correct
14 Correct 12 ms 23744 KB Output is correct
15 Correct 16 ms 24344 KB Output is correct
16 Correct 19 ms 25000 KB Output is correct
17 Correct 22 ms 25560 KB Output is correct
18 Correct 13 ms 23764 KB Output is correct
19 Correct 14 ms 23796 KB Output is correct
20 Correct 16 ms 23752 KB Output is correct
21 Correct 15 ms 23708 KB Output is correct
22 Correct 17 ms 23816 KB Output is correct
23 Correct 13 ms 23812 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 13 ms 23776 KB Output is correct
26 Correct 12 ms 23820 KB Output is correct
27 Correct 13 ms 23764 KB Output is correct
28 Correct 15 ms 23764 KB Output is correct
29 Correct 55 ms 28108 KB Output is correct
30 Correct 21 ms 24848 KB Output is correct
31 Correct 38 ms 27656 KB Output is correct
32 Correct 28 ms 25720 KB Output is correct
33 Correct 49 ms 28032 KB Output is correct
34 Correct 37 ms 26248 KB Output is correct
35 Correct 42 ms 27796 KB Output is correct
36 Correct 45 ms 26848 KB Output is correct
37 Correct 41 ms 27980 KB Output is correct
38 Correct 49 ms 27468 KB Output is correct
39 Correct 45 ms 27784 KB Output is correct