Advertisement

1390:食物链【NOI2001】

阅读量:

1390:食物链【NOI2001

复制代码
 //示例代码

    
 #include <iostream>
    
 #include <cstdio>
    
 using namespace std;
    
  
    
 const int N=150005;   // 定义常量 N,表示数组大小
    
 int n,k,F;           // n 表示点的数量,k 表示操作数, F 表示不合法的操作数。
    
 int f[N];            // 数组 f 存储点的祖先
    
  
    
 // 并查集中的查找操作,实现路径压缩
    
 int find(int x){
    
     if(f[x]==x) return f[x];
    
     return f[x]=find(f[x]);
    
 }
    
  
    
 // 并查集中的合并操作
    
 void unionn(int x,int y){
    
     x=find(x);
    
     y=find(y);

全部评论 (0)

还没有任何评论哟~