ural 1272. Non-Yekaterinburg Subway
1272. Non-Yekaterinburg Subway
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
6 3 4 |
2 |
Problem Source: Ural State University championship, October 25, 2003
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name)
{
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = , M = ;
int n, m, k;
int Fa[N];
inline void Input()
{
scanf("%d%d%d", &n, &m, &k);
} inline int Find(int x)
{
static int Arr[N], Length;
Length = ;
while(x != Fa[x])
{
Arr[++Length] = x;
x = Fa[x];
}
For(i, , Length) Fa[Arr[i]] = x;
return x;
} inline void Solve()
{
For(i, , n) Fa[i] = i;
For(i, , m)
{
int u, v;
scanf("%d%d", &u, &v);
u = Find(u), v = Find(v);
if(u != v) Fa[u] = v;
} int Ans = ;
For(i, , n)
if(Find(i) == i) Ans++;
printf("%d\n", Ans - );
} int main()
{
#ifndef ONLINE_JUDGE
SetIO("H");
#endif
Input();
Solve();
return ;
}
ural 1272. Non-Yekaterinburg Subway的更多相关文章
- URAL(timus) 1272 Non-Yekaterinburg Subway(最小生成树)
Non-Yekaterinburg Subway Time limit: 1.0 secondMemory limit: 64 MB A little town started to construc ...
- ural 1273. Tie
1273. Tie Time limit: 1.0 secondMemory limit: 64 MB The subway constructors are not angels. The work ...
- ural 1217. Unlucky Tickets
1217. Unlucky Tickets Time limit: 1.0 secondMemory limit: 64 MB Strange people live in Moscow! Each ...
- Ural 1086 - Cryptography
While preparing this problem set the jury has run into the following problem: it was necessary to se ...
- Ural 1319 - Hotel
You programmers are lucky! You don't have to deal with these terrible people – designers… This st ...
- Ural 1313 - Some Words about Sport
Ural doctors worry about the health of their youth very much. Special investigations showed that a l ...
- Ural State University Internal Contest October'2000 Junior Session
POJ 上的一套水题,哈哈~~~,最后一题很恶心,不想写了~~~ Rope Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7 ...
- URAL 2092 Bolero 贪心
C - Bolero Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit S ...
- 第一次作业——subway
作业源程序代码:https://github.com/R-81/subway 作业程序使用说明:通过输入命令参数求解路线(仅支持-b,-c),根据参数得出路线后,程序不会结束,此时可输入地铁路线名(例 ...
随机推荐
- iOS UILabel圆角
对于UIView 直接设置 uiview.layer.cornerRadius = 5 就可以有圆角了 但是对于UILabel则不然, 要多设置一个uilabel.clipsToBounds = YE ...
- onfiguration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Una ...
- poj1258 Agri-Net 最小生成树
Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 44032 Accepted: 18001 Descri ...
- iPhone取消软件更新上边的1
去除设置的更新+1小红点提示主要分为越狱和非越狱设备两种方法. 越狱状态下方法: 首先将你的设备进行越狱: 越狱后安装ifile(这个自行搜索安装): 用ifile打开/System/Library/ ...
- 【SpringMVC】SpringMVC系列7之POJO 对象绑定请求参数值
7.POJO 对象绑定请求参数值 7.1.概述 Spring MVC 会按请求参数名和 POJO 属性名进行自动匹配,自动为该对象填充属性值.而且支持级联属性.如:dept.deptId.dept ...
- petri网学习心得
本文转载自duxw,如给您带来不便之处,请联系博主. 1.Petri网书籍:<petri网导论>,吴哲辉 非常适合初学者.概念清晰,容易理解. 2.工作流书籍:<Workflow M ...
- 数据库路由器 ICX
实时并发数据库事务处理同步复制器和负载平衡器 ———通向真正数据库高可用性,高可靠性,高性能之路 一.产品概述 数据库路由器--ICX是美国宾夕法尼亚大学计算机系施教授经过多年研究.开发出 ...
- Hadoop 中文编码相关问题 -- mapreduce程序处理GBK编码数据并输出GBK编码数据(转)
hadoop的hdfs文件系统中,默认的是utf-8, 故你上传的文件是要设置成utf-8.当输入的是gbk,有该如何? 输入是GBK文件, 输出也是 GBK 文件的示例代码: Hadoop处理GBK ...
- 一、HTML和CSS基础--HTML+CSS基础课程--第2部分
第三章 与浏览器交互,表单标签 使用表单标签,与用户交互 网站怎样与用户进行交互?答案是使用HTML表单(form).表单是可以把浏览者输入的数据传送到服务器端,这样服务器端程序就可以处理表单传过来的 ...
- Android中几种定位 方式
介绍的几种定位方式 http://www.cnblogs.com/cuihongyu3503319/p/3863867.html 百度地图api: http://lbsyun.baidu.com/in ...