Submission #900562

# Submission time Handle Problem Language Result Execution time Memory
900562 2024-01-08T14:36:06 Z HamzaT Cijanobakterije (COCI21_cijanobakterije) C++14
0 / 70
28 ms 17908 KB
//struct Edge {int u, v, weight;bool operator<(Edge const& other) {return weight < other.weight;}};
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define sp ' '
#define pb push_back
#define ar for(int i=1;i<=n;i++)
using namespace std;
ll t=1;
const ll N=3e5+100;
ll n,m,q,k;
ll a[N],b[N],c[N];
bool vis[N];
ll mx=0;
vector<int>v[N];
void dfs(ll x,ll y)
{
    vis[x]=1;mx=max(mx,y);
    for(auto i:v[x])
    {
        if(!vis[i]){dfs(i,y+1);}
    }
}
ll ans=0;
void solve()
{
    cin>>n>>m;
    while(m--)
    {
        ll x,y;cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]&&v[i].size()==1)
        {mx=0;
            dfs(i,1);
            ans+=mx;
        }
    }
    cout<<ans<<endl;return;
}
int main()
{
    //freopen("shell.in", "r", stdin);
   // freopen("shell.out", "w", stdout);
    ios::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    // cin>>t;
    while(t--){solve();}
    return 0;
}
//09:00 :: 9:45
//10:30 ::
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 17908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9564 KB Output isn't correct
2 Halted 0 ms 0 KB -