雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年2月24日

摘要: 这道题目oj比较奇怪,用g++提交可以,c++就不行了……思路:e[]保存敌人输入时:d,x,y时fx=find(x),fy=find(y)如果e[fx]==-1;e[fx]=fy否则 合并(e[fx],fy);对fy再做如上操作View Code #include<stdio.h>#include<iostream>using namespace std;#define N 100009int f[N];int e[N];int find(int pos){ if(f[pos]==-1)return pos; else f[pos]=find(f[pos]);}int 阅读全文

posted @ 2011-02-24 21:40 huhuuu 阅读(305) 评论(0) 推荐(0) 编辑

摘要: View Code #include<stdio.h>int f[30009];int find(int pos){ if(f[pos]==-1)return pos; return f[pos]=find(f[pos]);}int un(int a,int b){ int fa=find(a),fb=find(b); if(fa==fb)return 0; f[fa]=fb; return 1;}int main(){ int n,m,i,j,add,one,temp; while(scanf("%d%d",&n,&m),n||m) { for 阅读全文

posted @ 2011-02-24 14:39 huhuuu 阅读(262) 评论(0) 推荐(0) 编辑