Submission #676121

# Submission time Handle Problem Language Result Execution time Memory
676121 2022-12-29T11:23:23 Z Tangirkul Cijanobakterije (COCI21_cijanobakterije) C++17
12 / 70
28 ms 13192 KB
#include<bits/stdc++.h>
  
#define ll long long
#define fi first
#define se second
#define pb push_back
#define sz size
#define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  
using namespace std;
  
const ll K = 32;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = (1e5 + 125);
 
ll n, m;
vector <ll> g[N];
bool used[N];

ll dfs (ll v, ll st)
{
    used[v] = 1;
    ll ans1 = 0;
    for (ll i = 0; i < g[v].sz (); i++)
    {
        ll to = g[v][i];
        if (!used[to])
        {
            ans1 = max (ans1, dfs (to, st));
        }
    }
    return ans1 + 1;
}

void ma1n ()
{
    cin >> n >> m;
    ll ans = 0;
    for (ll i = 1; i <= m; i++)
    {
        ll x, y;
        cin >> x >> y;
        g[x].pb (y);
        g[y].pb (x);
    }
    for (ll i = 1; i <= n; i++)
    {
        if (!used[i] && g[i].sz () <= 1)
        {
            ans += dfs (i, i);
        }
    }
    cout << ans;
}
    
int main ()
{
    Junanna;
    ll t = 1;
    while (t--)
    {
        ma1n ();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'long long int dfs(long long int, long long int)':
Main.cpp:25:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (ll i = 0; i < g[v].sz (); i++)
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 13192 KB Output is correct
2 Correct 3 ms 3060 KB Output is correct
3 Correct 6 ms 3668 KB Output is correct
4 Correct 9 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2684 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 4 ms 3284 KB Output is correct
6 Correct 9 ms 4052 KB Output is correct
7 Correct 9 ms 4736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -