Corporative Network LA3027
来源:互联网 发布:网络大电影商业计划书 编辑:程序博客网 时间:2024/06/05 04:41
#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>int f[20500][2];void inser(int x, int y){ f[x][0] = y; f[x][1] = abs(x-y)%1000;}int find(int x){ int tmp; if(f[x][0] != x) { tmp = f[x][0]; f[x][0] = find(f[x][0]); f[x][1] += f[tmp][1]; } return f[x][0];}int main(){ int i, t, n, a, b; char ch; scanf("%d", &t); while(t--){ scanf("%d", &n); for( i=0; i<=n ;i++){ f[i][0] = i; f[i][1] = 0; } while(scanf(" %c", &ch), ch!='O') { if(ch=='I'){ scanf("%d%d", &a, &b); inser(a, b); } else{ scanf("%d", &a); find(a); printf("%d\n", f[a][1]); } } } return 0;}
0 0
- Corporative Network LA3027
- LA3027 - Corporative Network,并查集
- LA3027:Corporative Network(并查集)
- LA3027 Corporative Network 带权并查集入门
- LA3027:Corporative Network(并查集) uva 1329
- Corporative Network
- Corporative Network
- Corporative Network
- Corporative Network
- poj Corporative Network
- poj 1962 Corporative Network
- LA - 3027 - Corporative Network
- LA--3027--Corporative Network
- POJ1962 Corporative Network
- POJ-1962-Corporative Network
- poj1962 Corporative Network
- LA 3027 Corporative Network
- LA 3027 - Corporative Network
- nyoj.733 万圣节派对【水题】 2015/03/15
- android蓝牙4.0(BLE)开发之ibeacon初步
- ButterKnife源码分析
- HDU ACM 1856 More is better->并查集
- mongodb 数据库创建和删除
- Corporative Network LA3027
- 将博客搬至CSDN
- 如何使用自定义注解。
- Intellij IDEA 14.0修改配置路径
- 【C++知识点总结】运算符 & 运算符重载
- 用XMPP协议来创建自己的即时聊天app
- git常用命令总结上
- 黑马程序员——java基础 io 字节流
- 使用自定义注解实例2