Submission #685011

# Submission time Handle Problem Language Result Execution time Memory
685011 2023-01-23T05:24:57 Z moonhero Newspapers (CEOI21_newspapers) C++14
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int p[1005];

int get (int x) {
    if (x == p[x]) return x;
    return p[x] = get(p[x]);
}

void u (int x, int y) {
    x = get(x), y = get(y);
    if (x == y) return;
    p[x] = y;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    bool ok = 1;
    for (int i = 1; i <= n; i++) p[i] = i;
    for (int i = 1; i <= m; i++) {
        int x, y; cin >> x >> y;
        if (get(x) == get(y)) ok = 0;
        u(x, y);
    } 
    if (ok) cout << "YES\n0";
    else cout << "NO\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=k] equals to 0, violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=k] equals to 0, violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=k] equals to 0, violates the range [1, 5]
2 Halted 0 ms 0 KB -