【poj 2983】Is the Information Reliable? 差分约束

解决VMware虚拟机网络时长中断的问题 1. 操作环境VMware VMware® Workstation 14 Pro Windows Win7旗舰版 2. 操作过程  VMware虚拟机在使用一段时间后,经常会出现时常断网的情况,而且这种情况也非常的让人头疼,因为我们在使用虚拟机的时候绝大多数是有联网需求的,如果虚拟机不能联网,那么我们使用该虚拟机的目的又有何在?!  解决的办法是这样的,在虚拟机的主面板中,选中要修改的虚拟机,比如说 阅读详情

题目:http://poj.org/problem?id=2983

Is the Information Reliable?
Time Limit: 3000MS Memory Limit: 131072K
Total Submissions: 12535 Accepted: 3943

Description

The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations. Because of the cooperation of the stations, Zibu’s Marine Glory cannot march any further but stay outside the line.

A mystery Information Group X benefits form selling information to both sides of the war. Today you the administrator of Zibu’s Intelligence Department got a piece of information about Grot’s defense stations’ arrangement from Information Group X. Your task is to determine whether the information is reliable.

The information consists of M tips. Each tip is either precise or vague.

Precise tip is in the form of P A B X, means defense station A is X light-years north of defense station B.

Vague tip is in the form of V A B, means defense station A is in the north of defense station B, at least 1 light-year, but the precise distance is unknown.

Input

There are several test cases in the input. Each test case starts with two integers N (0 < N ≤ 1000) and M (1 ≤ M ≤ 100000).The next M line each describe a tip, either in precise form or vague form.

Output

Output one line for each test case in the input. Output “Reliable” if It is possible to arrange N defense stations satisfying all the M tips, otherwise output “Unreliable”.

Sample Input
3 4
P 1 2 1
P 2 3 1
V 1 3
P 1 3 1
5 5
V 1 2
V 2 3
V 3 4
V 4 5
V 3 5

Sample Output
Unreliable
Reliable

Source

POJ Monthly–2006.08.27, Dagger

题意:n个点,告诉m个a,b间(有向)路径长度或路径长度>=1;求信息有误否。

思路:差分约束系统,建边
1.a-b>=c  b-a>=-c
2.a-b>=1;
‘>=’建最小边,spfa最长路,更新次数>=n—->有环—》false;

代码:

#include<iostream>
#include<stdio.h>
#include<vector>
#include<string.h>
#include<queue>
using namespace std;

int n,m;
char s[3];
int aa,bb,cc;
int tot;
struct nod{
    int x,v;
    nod(int xx,int vv)
    {
        x=xx,v=vv;
    }nod(){}
};
vector<nod> lin[1005];
int vis[1005],d[1005];
int cnt[1005];
queue<int> Q;
bool spfa()
{
    Q.push(0);
    d[0]=0;
    vis[0]=1;
    while(!Q.empty())
    {
        int now=Q.front();
        Q.pop();
        vis[now]=0;

        for(int i=0;i<lin[now].size();i++)
        {
            int v=lin[now][i].x;
            int vv=lin[now][i].v;

            if(d[v]==-1||d[v]<d[now]+vv)
            {

                d[v]=d[now]+vv;
                cnt[v]++;
                if(cnt[v]>n)
                {
                    return false;
                } 
                if(!vis[v])
                {
                    vis[v]=1;
                    Q.push(v);
                }
            }
        }
    }
    return 1;
}
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            lin[i].clear();
            d[i]=-1;
            vis[i]=0;
            cnt[i]=0;
        }
        for(int i=1;i<=m;i++)
        {

            scanf("%s",s);
            if(s[0]=='P')
            {
                scanf("%d%d%d",&aa,&bb,&cc);
                lin[aa].push_back(nod(bb,cc));
                lin[bb].push_back(nod(aa,-cc));
            } 
            else  if(s[0]=='V') 
            {
                scanf("%d%d",&aa,&bb);
                lin[aa].push_back(nod(bb,1));
            }
        }
        for(int i=1;i<n;i++)
        {
            lin[0].push_back(nod(i,0));
        }

        if(!spfa())
        printf("Unreliable\n");
        else printf("Reliable\n");


    }
}
SAP Integration Suite 与 SAP Cloud Integration 的关系解析 SAP Cloud Integration是SAP Integration Suite套件的核心组件,专注于消息与流程集成。两者关系可概括为:Integration Suite是SAP BTP上的集成平台套件(iPaaS),而Cloud Integration是其中负责应用与B2B集成的关键能力。日常所说的"CPI"实际指代的是Integration Suite中的Cloud Integration功能。该套件还包含API管理、事件网格等其他集成能力,共同构成企业集成解决方案。理解这一层 阅读详情

相关推荐

SAP PPDS启发式排产实战:从零配置到自定义规则开发(附ABAP代码示例)

本文详细介绍了SAP PPDS启发式排产的实战应用,从基础配置到自定义规则开发的全流程。通过ABAP代码示例,展示了如何实现多目标优化、实时响应和约束可视化,帮助企业提升订单交付率、减少设备闲置时间。文章还包含开发环境准备、标准模板解析、自定义开发步骤及性能优化技巧,适合制造业数字化转型的实践参考。

seed的博客 196

【图论·习题】差分约束系统:Is the Information Reliable?

problem The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations. Be...

Ronaldo7_ZYB的博客 271

BUUCTF--[OGeek2019]babyrop

才学习了基本的ROP流程,到处找题练,不过也没做出来几道题,以这道32位的题作为例题吧。 这道题是BUUCTF上pwn练习题里的[OGeek2019]babyrop。 代码审计 老规矩先checksec一下: 没有canary保护,nx保护开启排除shellcode可能性,FULL RELEO为地址随机化。 观察主函数,先设定了一个闹铃,到时间就会强制退出程序,解除闹铃的方法在上一篇博客中提到过了, 这道题中闹铃函数依然对我们解题起不到什么干扰作用。 主函数的思路大概是:生成一个随机数,把这个随机数作为

N1rvana的博客 6014

POJ2983 Is the Information Reliable?

http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=267#problem/B                        B - Is the Information Reliable? Time Limit:3000MS     Memory Limit:131072KB     64bit IO Format:%I6...

weixin_34095889的博客 197

施密特触发电路详细原理介绍

我们想获得矩形脉冲,有种方法是可以采用整形的方法获得矩形脉冲,但前提是可以找到频率和幅度都符合要求的电压信号。 我们设定矩形脉冲的几个指标。 施密特电路是脉冲波形变换中一种常采用的电路,主要有以下两个特点: 1.输入电平从低电平上升过程中电路状态转换为对应的输入电平,与高电平下降过程中对应的输入转换电平不同。 2.通过电路内部的正反馈使输出电压波形的边沿变得很陡。 施密特电路的结构和工作原理 我们先从模电的角度来分析此电路的工作原理。 此电路是通过公共发射极电阻耦合的两级正反馈放大器。 v1输入为低电平

fcxgfdjy的博客 1万+

MATLAB实战:利用扫频数据重构系统伯德图的关键步骤

本文详细介绍了如何利用MATLAB处理扫频数据并重构系统伯德图的完整实战流程。内容涵盖数据导入与清洗、增益与相位的精确计算、频率响应数据对象(frd)的构建、数据平滑与插值处理,以及最终生成专业伯德图并进行关键参数(如相位裕度)标注的方法。文章重点解决了从实测“黑盒子”系统数据出发,获取直观频率响应特性曲线的核心问题,为控制系统分析与设计提供了实用指南。

weixin_29098117的博客 401

[poj2983] Is the Information Reliable? 差分约束系统

Is the Information Reliable?Time Limit: 3000MS Memory Limit: 131072K Total Submissions: 13602 Accepted: 4268 DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zib

Unlimited Code Works 487

acados安装与调试指南:版本兼容性问题

在计算机编程领域,软件工具和库的安装与调试是每个开发者必经的挑战。最近,在安装和使用acados库时,我遇到了一个有趣的问题,这里我将详细分享我的经验和解决方案。

m0_62153576的博客 746

POJ_2983_Is the Information Reliable? _差分约束

Is the Information Reliable? Time Limit: 3000MS        Memory Limit: 131072K Total Submissions: 12466        Accepted: 3924 Description The galaxy war between the Empire Draco and the Commonwe

持之以恒_fighting 541

95.qt qml-诺谦通用可扩展多功能QML界面

如下图所示:自带一个功能界面,可以通过功能界面添加不同功能,并且可以固定到顶部水平导航栏中,对于N多小功能的项目而言,非常方便,这样用户就可以根据自己喜好来使用自己常用的功能了。

抵抗时间扭曲,坚持做一件有意义的事 3051

170、电机控制中的温升测试

本文以一次IGBT炸管事故为切入点,深入剖析电机控制中温升测试的实质:不仅是温度测量,更是对铜损、铁损、散热效率等热管理问题的系统验证。作者强调测试前热电偶布置、环境记录、预运行的重要性,提出实时监控电流谐波、绕组电阻、散热梯度等关键参数,并通过损耗分离与冷却系统实测,揭示真实热源。结合温升曲线异常分析与经验建议,强调留余量、仿真结合实测、关注瞬态工况等实践要点,警示温升测试是保障可靠性与安全性的核心环节。

2401_88858637的博客 59

Is the Information Reliable?(差分约束)

Is the Information Reliable?Crawling in process... Crawling failed Time Limit:3000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Description The gala

Rocky0429 1709

【YOLOv11改进[Backbone]】 使用Ghostnetv2替换Backbone

使用Ghostnetv2替换Backbone

静谧、淡雅 522

poj2983Is the Information Reliable?——差分约束

poj2983Is the Information Reliable?:http://poj.org/problem?id=2983 Is the Information Reliable? Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 12379   Accepted: 3

hahaAll的博客 443

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

[POJ 2983]Is the Information Reliable?[差分约束]

题目链接:[POJ 2983]Is the Information Reliable?[差分约束] 题意分析: 给出N个防御站和M个提示,提示P代表A站在B站的北方X米处,提示V代表,A站在B站北方至少1米处,现在问:给出的这M个提示是否可信? 解题思路: 对于P操作,我们得知dis[B] - dis[A] == x 转换为:dis[B] - dis[A] = x,再根据V,得知:dis[

闲停 526

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

POJ 2983-Is the Information Reliable?(差分约束系统)

题目地址:POJ 2983 题意:有N个车站,给出一些点的精确信息和模糊信息,精确信息给出两点的位置和距离,模糊信息给出两点的位置,但距离大于等于一。试确定是否所有的信息满足条件。 思路:其实就是让你判断是否存在负环。好久才看明白。对于精确消息,可以得出两个差分公式:dis[v] dis[v] PS:做差分约束感觉还是Bellman_ford好用啊。 #include #include

Rocky0429 1550

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【POJ 2983】Is the Information Reliable?(差分约束系统)

【POJ 2983】Is the Information Reliable?(差分约束系统) Is the Information Reliable? Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 12244   Accepted: 3861 Des

ACMer' 1568

POJ 2983 Is the Information Reliable? 差分约束

POJ 2983 Is the Information Reliable? 差分约束

NNDXNM的专栏 767

POJ_2983 Is the Information Reliable?(差分约束)

Is the Information Reliable? Time Limit: 3000MS Memory Limit: 131072K Problem Description The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line

sigh_的博客 222

POJ 2983 Is the Information Reliable?(差分约束)

Is the Information Reliable? Time Limit:3000MS Memory Limit:131072K Total Submissions:15753 Accepted:4884 Description The galaxy war between the Empire Draco and the Commonwe...

LSD20164388的博客 250

poj 2983 Is the Information Reliable?(差分约束)

啊!啊!啊!快要哭了,调了一下午加一晚上,怎么也找不出错误,感觉自己理解的也没错,怎么就是不对呢,在我要崩溃的时候终于AC了,原因竟然是因为判断条件没用函数,真的崩溃了!!题意:给出N个点,有些点的位置是清晰的, 有些点的位置不清楚,只知道点A在点B的北面,清晰的点有两点间的距离, 不清晰的点只知道两点的距离不小于1。 思路:这题时用差分约束做的,刚开始接触差分约束,知道要先找到不等式...

B218707的博客 208

poj 2983 差分约束Is the Information Reliable?

一天一道题。。。今天写解题报告,明天回顾。。。 题目链接:http://poj.org/problem?id=2983 第一道差分约束题啊。。。 题意:有N个车站,给出一些点的精确信息和模糊信息,精确信息给出两点的位置和距离,模糊信息给出两点的位置,但距离大于等于一。试确定是否所有的信息满足条件 对于精确信息,可以得出两个差分条件,b-a = c;可以化为b 对于模糊信息,只能得出一个

以现在的努力程度之低,谈狗屁的未来,屎的梦想!!! 1575

poj 2983 Is the Information Reliable? (差分约束)

Is the Information Reliable? Time Limit:3000MS Memory Limit:131072K Total Submissions:10303 Accepted:3204 Description The galaxy war between the Empire Draco...

anque1234的博客 172

POJ - 2983 Is the Information Reliable 【spfa解决差分约束问题】

题目链接:http://poj.org/problem?id=2983 原理在上篇博客已经讲过了,这里把要注意的讲下。 1,因为差分约束问题都是不等式约束,以不等式为基础给题目建图,但是如果题目给出的约束条件是 d[u] - d[v] == w,怎么处理? w &lt;= d[u] - d[v] &lt;=w,这样就能表示d[u] - d[v] == w这个条件,一条正向正权值,一条反向负...

Y390d的博客 159

poj 2983 Is the Information Reliable? 差分约束

题目链接:poj 2983         给定一些条件的先后

飞火扑蛾的专栏 532

POJ_2983_Is the Information Reliable?(差分约束)

The galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stations. Because of...

weixin_43244265的博客 145
上一篇: [poj 1201]Intervals 差分约束
下一篇: 【poj 3159】Candies 差分约束+spfa(stack)
ALPS233
博客等级 码龄11年 25粉丝 191原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值