Submission #16738150


Source Code Expand

# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 2e5 + 7;
const int mod = 1e9 + 7;

vector < int > adj[N];
int used[N], cnt, mx;

void dfs( int v ) {
    used[v] = 1;
    cnt++;
    for ( auto u: adj[v] ) {
        if ( !used[u] ) {
            dfs( u );
        }
    }
}

int32_t main() {
    speed;
    int n, m;
    cin >> n >> m;
    for ( int i = 0; i < m; i++ ) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for ( int i = 1; i <= n; i++ ) {
        if ( !used[i] ) {
            cnt = 0;
            dfs( i );
            mx = max( mx, cnt );
        }
    }
    cout << mx;
}

Submission Info

Submission Time
Task D - Friends
User Dilshod_Imomov
Language C++ (GCC 9.2.1)
Score 400
Code Size 895 Byte
Status AC
Exec Time 114 ms
Memory 25380 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 29
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_11.txt, random_12.txt, random_13.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_31.txt, random_32.txt, random_33.txt, random_41.txt, random_42.txt, random_43.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 13 ms 9700 KiB
hand_02.txt AC 7 ms 8284 KiB
hand_03.txt AC 8 ms 8148 KiB
random_01.txt AC 100 ms 18548 KiB
random_02.txt AC 16 ms 10480 KiB
random_03.txt AC 68 ms 15192 KiB
random_04.txt AC 25 ms 10080 KiB
random_05.txt AC 70 ms 15884 KiB
random_06.txt AC 58 ms 13976 KiB
random_07.txt AC 59 ms 14120 KiB
random_08.txt AC 12 ms 9616 KiB
random_11.txt AC 48 ms 13508 KiB
random_12.txt AC 67 ms 16844 KiB
random_13.txt AC 52 ms 14780 KiB
random_21.txt AC 67 ms 25376 KiB
random_22.txt AC 62 ms 25380 KiB
random_23.txt AC 61 ms 16956 KiB
random_24.txt AC 57 ms 16936 KiB
random_25.txt AC 54 ms 16104 KiB
random_26.txt AC 58 ms 16188 KiB
random_31.txt AC 37 ms 13616 KiB
random_32.txt AC 43 ms 12484 KiB
random_33.txt AC 49 ms 11796 KiB
random_41.txt AC 114 ms 18416 KiB
random_42.txt AC 114 ms 18404 KiB
random_43.txt AC 107 ms 18440 KiB
sample_01.txt AC 9 ms 8208 KiB
sample_02.txt AC 7 ms 8284 KiB
sample_03.txt AC 11 ms 8208 KiB