社区讨论

???RE???

P1196[NOI2002] 银河英雄传说参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@m4y3arje
此快照首次捕获于
2024/12/21 19:22
去年
此快照最后确认于
2025/11/04 12:31
4 个月前
查看原帖
CPP
#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了????

回复

2 条回复,欢迎继续交流。

正在加载回复...