255032026-02-20 12:35:38KevinSportos nyaraláscpp17Wrong answer 1/4046ms1616 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll, ll>;

vector<ll> bicikli, kajak;

ll rootB(ll x){
    if (bicikli[x]==x) return x;
    else bicikli[x]=rootB(bicikli[x]);
    return bicikli[x];
}

ll rootK(ll x){
    if (kajak[x]==x) return x;
    else kajak[x]=rootK(kajak[x]);
    return kajak[x];
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n, m, k; cin >> n >> m >> k;
    bicikli.resize(n); kajak.resize(n);
    for (ll i=0; i<n; i++){
        bicikli[i]=i; kajak[i]=i;
    }
    for (ll i=0; i<m; i++){
        ll a, b; cin >> a >> b; a--; b--;
        if (a>b) swap(a, b);
        bicikli[b]=a;
    }
    vector<ll> out(n);
    for (ll i=0; i<k; i++){
        ll a, b; cin >> a >> b; a--; b--;
        if (a>b) swap(a, b);
        kajak[b]=a;
        if (rootB(a)==rootB(b) && rootK(a)==rootK(b)){
            out[a]++; out[b]++;
        }
    }
    for (auto& z:out) cout << z << ' ';
}
SubtaskSumTestVerdictTimeMemory
base1/40
1Accepted0/01ms500 KiB
2Wrong answer0/032ms1588 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/11ms316 KiB
6Wrong answer0/11ms348 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Wrong answer0/11ms316 KiB
10Wrong answer0/12ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/22ms316 KiB
13Wrong answer0/26ms316 KiB
14Wrong answer0/24ms436 KiB
15Wrong answer0/212ms1140 KiB
16Wrong answer0/217ms1320 KiB
17Wrong answer0/318ms1608 KiB
18Wrong answer0/319ms1608 KiB
19Wrong answer0/221ms1144 KiB
20Wrong answer0/229ms1432 KiB
21Wrong answer0/230ms1616 KiB
22Wrong answer0/228ms1588 KiB
23Wrong answer0/339ms1608 KiB
24Wrong answer0/346ms1588 KiB