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 ...
随机推荐
- 微软职位内部推荐-Software Development Engineer II
微软近期Open的职位: Job Title:Software Development EngineerII Division: Server & Tools Business - Comme ...
- what are Datatypes in SQLite supporting android
As said at Datatypes In SQLite Version 3: Datatypes In SQLite Version 3 Most SQL database engines (e ...
- When to use Class.isInstance() & when to use instanceof operator?
I think the official documentation gives you the answer to this one (albeit in a fairly nonspecific ...
- ios的UIImage的两种不同的图片加载方式 tom猫
在ios的UI交互设计时,对图片的处理是难免的:不同的处理方式会对内存有不同的影响: ********************************************************* ...
- 自己的一些 Demo,源码链接
1.指纹解锁(GitHub). 2.JS 与 OC 交互(GitHub). 3.模仿 HTML 下拉菜单(GitHub). 4.OC开发常用类目(GitHub).
- struts2传map到前台出现的问题
后台打印出的错: 2016-08-16 13:42:52.652 WARN org.apache.struts2.json.JSONWriter - JavaScript doesn't s ...
- iOS上用FTGL显示定制Truetype字体碰到的问题
没想到这个问题搞了快2个月时间:当然跟我只是断断续续地工作有关. FTGL是freetype的opengl实现.我接触FTGL最初只是为了练习OpenGL,写几个简单的游戏app.开始试了试FTGL觉 ...
- POJ 1680 Fork() Makes Trouble
原题链接:http://poj.org/problem?id=1680 对这道题,我只能说:我不知道题目是什么意思,但是AC还是没有问题的. 看来题目半天没明白fork()怎么个工作,但是看样例(根据 ...
- PrintQueue
PrintQueueCollection printQueues = null; var printServer = new PrintServer(); printQueues = printSer ...
- uva 1056
floyd 算法 用了stl 的map 存名字的时候比较方便 #include <cstdio> #include <cstdlib> #include <cmath&g ...