255022026-02-20 12:35:28KevinSportos nyaraláspython3Runtime error 0/4017ms3236 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
base0/40
1Runtime error0/014ms3064 KiB
2Runtime error0/016ms2860 KiB
3Runtime error0/116ms2832 KiB
4Runtime error0/116ms2868 KiB
5Runtime error0/114ms3236 KiB
6Runtime error0/116ms2988 KiB
7Runtime error0/114ms3036 KiB
8Runtime error0/114ms2872 KiB
9Runtime error0/116ms3064 KiB
10Runtime error0/116ms2888 KiB
11Runtime error0/216ms2868 KiB
12Runtime error0/216ms3064 KiB
13Runtime error0/216ms2876 KiB
14Runtime error0/214ms3012 KiB
15Runtime error0/214ms2956 KiB
16Runtime error0/216ms2868 KiB
17Runtime error0/317ms2976 KiB
18Runtime error0/316ms2868 KiB
19Runtime error0/217ms2868 KiB
20Runtime error0/217ms3064 KiB
21Runtime error0/217ms2868 KiB
22Runtime error0/216ms2868 KiB
23Runtime error0/316ms2868 KiB
24Runtime error0/316ms3064 KiB