255082026-02-20 12:47:50KevinSportos nyaraláscpp17Time limit exceeded 1/401.1s1588 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;
    return bicikli[x]=rootB(bicikli[x]);
}

ll rootK(ll x){
    if (kajak[x]==x) return x;
    return kajak[x]=rootK(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, 0);
    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 (ll i=0; i<n-1; i++){
        for (ll j=i+1; j<n; j++){
            if (rootB(i)==rootB(j) && rootK(i)==rootK(j)){
                out[i]++; out[j]++;
            }
        }
    }
    for (auto& z:out) cout << z << ' ';
}

SubtaskSumTestVerdictTimeMemory
base1/40
1Accepted0/01ms332 KiB
2Time limit exceeded0/01.085s1588 KiB
3Accepted1/11ms316 KiB
4Wrong answer0/11ms316 KiB
5Wrong answer0/11ms316 KiB
6Wrong answer0/11ms316 KiB
7Wrong answer0/11ms316 KiB
8Wrong answer0/11ms316 KiB
9Wrong answer0/11ms316 KiB
10Wrong answer0/12ms508 KiB
11Wrong answer0/24ms316 KiB
12Wrong answer0/22ms316 KiB
13Wrong answer0/28ms316 KiB
14Wrong answer0/27ms316 KiB
15Time limit exceeded0/21.09s1076 KiB
16Time limit exceeded0/21.1s1332 KiB
17Time limit exceeded0/31.1s1588 KiB
18Time limit exceeded0/31.088s1588 KiB
19Time limit exceeded0/21.09s1076 KiB
20Time limit exceeded0/21.1s1332 KiB
21Time limit exceeded0/21.1s1480 KiB
22Time limit exceeded0/21.075s1588 KiB
23Time limit exceeded0/31.09s1476 KiB
24Time limit exceeded0/31.1s1472 KiB