1227. Rally Championship
题意木看懂 是可以停在路上 任何地方
水题一枚 以下条件之一满足就可以
有环(并查集判)
重边
自己到自己的边
最长边大于s(用flod改写下)
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define LL long long
int m,n,s,f[];
int w[][];
int find(int x)
{
if(x!=f[x])
f[x] = find(f[x]);
return f[x];
}
int main()
{
int i,flag=,j,k;
scanf("%d%d%d",&n,&m,&s);
for(i = ; i <= n ; i++)
{
f[i] = i;
}
int maxz = ;
for(i = ; i <= m ; i++)
{
int u,v,c;
scanf("%d%d%d",&u,&v,&c);
maxz = max(maxz,c);
if(w[u][v])
flag = ;
if(u==v)
flag = ;
w[u][v] = c;
w[v][u] = c;
int tx = find(u),ty = find(v);
if(tx == ty)
{
flag = ;
}
else
f[tx] = ty;
}
if(flag)
{
printf("YES\n");
return ;
} for(i = ; i <= n ; i++)
for(j = ; j <= n ; j++)
for(k = ; k <= n ; k++)
if(j!=k&&j!=i&&i!=k&&w[j][k]==&&w[j][i]&&w[i][k])
{
w[j][k] = w[j][i]+w[i][k];
maxz = max(maxz,w[j][k]);
}
if(maxz>=s)
printf("YES\n");
else
printf("NO\n");
return ;
}
1227. Rally Championship的更多相关文章
- URAL 1227 Rally Championship(树的直径)(无向图判环)
1227. Rally Championship Time limit: 1.0 secondMemory limit: 64 MB A high-level international rally ...
- FC红白机游戏列表(维基百科)
1055个fc游戏列表 日文名 中文译名 英文版名 发行日期 发行商 ドンキーコング 大金刚 Donkey Kong 1983年7月15日 任天堂 ドンキーコングJR. 大金刚Jr. Donkey K ...
- BZOJ 1227: [SDOI2009]虔诚的墓主人
1227: [SDOI2009]虔诚的墓主人 Time Limit: 5 Sec Memory Limit: 259 MBSubmit: 1078 Solved: 510[Submit][Stat ...
- ZOJ 3699 Dakar Rally
Dakar Rally Time Limit: 2 Seconds Memory Limit: 65536 KB Description The Dakar Rally is an annu ...
- 【BZOJ-3832】Rally 拓扑序 + 线段树 (神思路题!)
3832: [Poi2014]Rally Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 168 Solved: ...
- HDU 1227 Fast Food
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1227 题意:一维坐标上有n个点,位置已知,选出k(k <= n)个点,使得所有n个点与选定的点中 ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
- 【wikioi】1227 方格取数 2(费用流)
http://www.wikioi.com/problem/1227 裸题,拆点,容量为1,费用为点权的负数(代表只能取一次).再在拆好的两个点连边,容量为oo,费用为0.(代表能取0) 然后向右和下 ...
- Codeforces Round #382 (Div. 2) C. Tennis Championship 斐波那契
C. Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
随机推荐
- LR(0)语法分析
# include <stdio.h> # include <string.h> //存储LR(0)分析表 struct node { char ch; int num; }; ...
- C# Windows - 创建控件
VS提供了一个项目类型Windows Control Library,使用它可以创建自己的控件. 可以开发两种不同类型的自定义控件: 用户或组合控件:这种控件是根据现有控件的功能创建一个新控件.这类控 ...
- clion windows 开发配置
1.下载clion 并且安装. 地址 : http://download-cf.jetbrains.com/cpp/clion-1.0.1.exe 2.安装cygwin 地址: https://cy ...
- OC面向对象多态笔记
面向对象的多态是建立在继承上,可以说没有继承就没有多态: 多态:父类指针指向了子类的对象: int main() { //假设已定义了Animal类和它的子类Dog,那么多态的代码体现就是 Anima ...
- C# 浅谈委托----温故而知新
先看看委托的概述: •委托类似于 C++ 函数指针,但它们是类型安全的. • 委托允许将方法作为参数进行传递. • 委托可用于定义回调方法. • 委托可以链接在一起:例如,可以对一个事件调用多个方法. ...
- c# 取 list前100条数据
[问] List<KeyWord> sortedList = (from a in keyWordList orderby a.Total descending select a).ToL ...
- 混乱的url编码||URL编码解码问题
转载自:http://www.ruanyifeng.com/blog/2010/02/url_encoding.html 一.问题的由来. url就是网址,只要上网就一定会用到. 一般来说,URL只能 ...
- [转载]Winform开发框架之统计图表的实现
在前面的一些随笔中,介绍了不少我的Winform框架的特性,上篇随笔<Winform开发框架之通用高级查询模块>对其中的通用高级模块进了一个整理说明,本篇继续介绍Winform开发框架重要 ...
- tomcat 解析(一)-文件解析
做web项目,最常用的服务器就是Apache的tomcat.虽然一直在用tomcat,但都是仅限在使用的阶段,一直没有深入学习过.想深入学习tomcat,首推的肯定是官网:http://tomcat. ...
- php浮点数精确运算
php浮点数精确运算 Php: BCMath bc是Binary Calculator的缩写.bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(strin ...