【判环】Perpetuum Mobile
Perpetuum Mobile
题目描述
• Every patent proposal contains n energy converters.
• Every converter has an unknown input energy unit associated with it.
• Some energy converters can be connected: If converter a can be connected to converter b such that one energy unit associated with a is turned into c input units for b, then this is indicated by an arc
 in the proposal. The output of a can be used as input for b if and only if such an arc from a to b exists.
 in the proposal. The output of a can be used as input for b if and only if such an arc from a to b exists.Einstein would like to dismiss all those proposals out of hand where the energy converters can be chained up in a cycle such that more energy is fed back to a converter than is given to it as input, thereby violating the law of conservation of energy.
Einstein’s assistants know that he is born for higher things than weeding out faulty patent proposals. Hence, they take care of the most difficult cases, while the proposals given to Einstein are of a rather restricted form: Every admissible patent proposal given to Einstein does not allow for a cycle where the total product of arc weights exceeds 0.9. By contrast, every inadmissible patent proposal given to Einstein contains a cycle where the the number of arcs constituting the cycle does not exceed the number of converters defined in the proposal, and the total product of arc weights is greater or equal to 1.1.
Could you help Einstein identify the inadmissible proposals?
输入
• one line with two integers n and m, where
– n (2 ≤ n ≤ 800) is the number of energy converters;
– m (0 ≤ m ≤ 4000) is the number of arcs.
• m lines each containing three numbers ai , bi , and ci , where
– ai and bi (1 ≤ ai , bi ≤ n) are integers identifying energy converters;
– ci (0 < ci ≤ 5.0) is a decimal number indicating that the converter ai can be connected to the converter b i such that one input unit associated with ai is converted to ci units associated with bi . The number ci may have up to 4 decimal places.
输出
样例输入
2 2
1 2 0.5
2 1 2.3
样例输出
inadmissible
【代码】
参考博客:
https://blog.csdn.net/qq_41955236/article/details/82959245
队友代码:
//
//
//
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC optimize("O3")
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
#define pi acos(-1.0)
#define nl "\n"
#define db double
#define pb push_back
#define pii pair<int,double>
#define ms(a,b) memset(a,b,sizeof(a))
#define FAST_IO ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const ll mod = 1e9+;
ll qpow(ll x, ll y){ll s=;while(y){if(y&)s=s*x%mod;x=x*x%mod;y>>=;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
inline int read(){int x=,f=;char ch=getchar();while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}while(ch>=''&&ch<='') x=x*+ch-'',ch=getchar();return x*f;} const int N = ; struct node{
int to;
db w;
}; vector <node> G[N];
db d[N];
int vis[N]; bool dijktra(int u)
{
vis[u] = ;
for(int i=;i<G[u].size();i++)
{
node v = G[u][i];
if(d[u]+v.w < d[v.to]){
d[v.to] = d[u]+v.w;
if(vis[v.to]) return ;
if(dijktra(v.to)) return ;
}
}
vis[u] = ;
return ;
} int main()
{
int n, m;
scanf("%d%d", &n,&m);
for(int i=;i<=m;i++){
int u, v;db w;
scanf("%d%d%lf",&u,&v,&w);
//if(w >= 1.1) w = -w;
G[u].pb((node){v,-log(w)});
}
for(int i=;i<=n;i++)if(dijktra(i)){
puts("inadmissible");
return ;
}
puts("admissible");
return ;
}
【判环】Perpetuum Mobile的更多相关文章
- hdu4975 A simple Gaussian elimination problem.(正确解法 最大流+删边判环)(Updated 2014-10-16)
		这题标程是错的,网上很多题解也是错的. http://acm.hdu.edu.cn/showproblem.php?pid=4975 2014 Multi-University Training Co ... 
- hdu4888 Redraw Beautiful Drawings 最大流+判环
		hdu4888 Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/6553 ... 
- Leetcode 166. Fraction to Recurring Decimal 弗洛伊德判环
		分数转小数,要求输出循环小数 如2 3 输出0.(6) 弗洛伊德判环的原理是在一个圈里,如果一个人的速度是另一个人的两倍,那个人就能追上另一个人.代码中one就是速度1的人,而two就是速度为2的人. ... 
- Leetcode 202 Happy Number 弗洛伊德判环解循环
		今天先谈下弗洛伊德判环,弗洛伊德判环原来是在一个圈内有两人跑步,同时起跑,一人的速度是另一人的两倍,则那个人能在下一圈追上另一个人,弗洛伊德判环能解数字会循环出现的题,比如说判断一个链表是不是循环链表 ... 
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
		K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ... 
- Dwarves (有向图判环)
		Dwarves 时间限制: 1 Sec 内存限制: 64 MB提交: 14 解决: 4[提交][状态][讨论版] 题目描述 Once upon a time, there arose a huge ... 
- COJ 3012 LZJ的问题 (有向图判环)
		传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1042 试题描述: LZJ有一个问题想问问大家.他在写函数时有时候很头疼,如 ... 
- 比赛F-F    Perpetuum Mobile
		比赛F-F Perpetuum Mobile 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/ ... 
- K. Perpetuum Mobile
		The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main par ... 
随机推荐
- 2018-2019-2 20165312《网络攻防技术》Exp7 网络欺诈防范
			2018-2019-2 20165312<网络攻防技术>Exp7 网络欺诈防范 目录 一.相关知识点总结 二.实验内容 三.实验步骤 四.实验总结及问题回答 五.实验中遇到的问题及解决方法 ... 
- qt QThread
			QThread类提供了一个平台无关的方式来管理线程. 一个QThread对象在程序控制中管理一个线程.线程在run()中开始执行.默认情况下,run()通过调用exec()启动事件循环并在线程里运行一 ... 
- 咏南中间件和开发框架全面支持DELPHI10.3.2
			咏南中间件和开发框架全面支持DELPHI10.3.2 易博龙公司2019年7月12日发布了RAD STUDIO10.3.2正式版本. 咏南中间件自2019年7月14日始,中间件.CS框架.WEB框架. ... 
- Flutter移动电商实战 --(53)购物车_商品列表UI框架布局
			cart_page.dart 清空原来写的持久化的代码; 添加对应的引用,stless生成一个静态的类.建议始终静态的类,防止重复渲染 纠正个错误,上图的CartPage单词拼错了,这里改过来防止后面 ... 
- JVM | JVM体系结构认知
			虚拟机 何为虚拟机呢?虚拟机是模拟执行某种指令集体系结构(ISA)的软件,是对操作系统和硬件的一种抽象.其软件模型如下图所示: 计算机系统的这种抽象类似于面向对象编程(OOP)中的针对接口编程泛型(或 ... 
- python @classmethod
			写在前面 写博客的时候,我发现拖延症很严重,本来昨天要开始写的,结果东看看,西翻翻,啥也没落实下来.时间过去了,口袋里的收获却寥寥无几.讨厌这样的自己.我要戒掉这个不好的毛病. 拖延症的底层原因之一是 ... 
- Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]
			最近在项目中遇到了 Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] 这个 ... 
- LinearGradient线型渐变效果
			public LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions, TileM ... 
- “kill -9” 和 “kill -15” 有什么不同
			来看下图,其中关键参数 -n signum 表示的是信号编码. kill kill 可以用 kill -l 来查看具体有哪些信号编码,这里重点关注 9) SIGKILL 和 15) SIGTE ... 
- 26 Flutter仿京东商城项目 购物车之 event_bus事件广播 事件监听
			event_bus 介绍 在前面的课程我们给大家讲过状态管理 Provider 的使用. 通俗的讲状态管理就是:当我们想在多个页面(组件/Widget)之间共享状态(数据),或 者一个页面(组件/Wi ... 
