???RE???
查看原帖
???RE???
1385468
msh20204401楼主2024/12/21 19:21
#include<bits/stdc++.h>
using namespace std;
int f[33333],infront[33333],num[33333],t,y,z,ans;
int fnt;
char c;
int find(int x){
    if(fa[x]==x)return f[x];
    else
    fnt=find(f[x]);
    infront[x]=infront[f[x]]+infront[x];
    f[x]=fnt;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        cin>>c>>y>>z;
        int fx=find(y);
        int fy=find(z);
        if(c=='M'){
           infront[fx]+=num[fy];
           f[fx]=fy;
           num[fy]+=num[fx];
           num[fx]=0;
        }
        else
        if(c=='C'){
            if(fx!=fy){
                cout<<-1<<endl;
            }
            else
            cout<<abs(infront[fx]-infront[fy])-1<<endl;
        }
    }
    return 0;
}

为什么RE了????

2024/12/21 19:21
加载中...