ACM: 并查集 poj 1703
来源:互联网 发布:java回退流 编辑:程序博客网 时间:2024/05/16 15:08
Assume N (N <= 10^5) criminals are currently in TaduCity, numbered from 1 to N. And of course, at least one of thembelongs to Gang Dragon, and the same for Gang Snake. You will begiven M (M <= 10^5) messages in sequence, which arein the following two kinds:
1. D [a] [b]
where [a] and [b] are the numbers of two criminals, and they belongto different gangs.
2. A [a] [b]
where [a] and [b] are the numbers of two criminals. This requiresyou to decide whether a and b belong to a same gang.
Input
Output
Sample Input
1
5 5
A 1 2
D 1 2
A 1 2
D 2 4
A 1 4
Sample Output
Not sure yet.
In different gangs.
In the same gang.
题意: police要分别2个犯罪集团的人, 有2种操作A[a][b]:判断[a],[b]是否在同一个集团里面.
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 100005
int n, m;
int p[MAX*2];
int a, b;
char ch[2];
void init()
{
}
int find(int x)
{
}
inline void union_set(int x, int y)
{
}
int main()
{
//
}
- ACM: 并查集 poj 1703
- ACM: 并查集 poj 2492
- poj 2236 并查集
- poj 1182 并查集
- poj 1703 并查集的拓展
- poj 1308 Is It A Tree?(并查集)
- poj 1182 并查集经典题…
- poj 1733 并查集+偏移向…
- 图论: 并查集 + kruskal 求最小…
- poj 1703_ 并查集+//方法同poj2492
- POj 2379 ACM Rank Table
- ACM: poj 1664
- ACM: poj 1050
- ACM: poj 1964
- ACM: poj 3141
- ACM: poj 1903
- ACM: 深搜 poj 2676
- ACM: 深搜题 poj 3411
- ACM: 树状数组 poj 2155 学习《浅…
- ACM: 树状数组 poj 3321 图论+树状…
- spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 并查集 poj 1703
- 凌宇的项目之旅-关于自定义锁屏
- 兴趣学习: 信息熵 ---- 《数学…
- ACM: 并查集 poj 2492
- ACM: 《黑书》高性能计算机
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj3280
- ACM: 树状数组 poj 2029 动态规划…
- ACM: 动态规划题 poj 2948