Poj 3713 Transferring Sylla 3-连通

《QGIS快速入门与应用基础》223:纸张大小与方向(A4/A3/自定义) 本文详细介绍了QGIS布局页面设置的核心操作,重点讲解了纸张大小与方向的设置方法。文章首先指出页面设置是地图排版的基础前提,强调合理设置可避免导出打印时出现尺寸不符等问题。随后详细说明了三种打开页面设置面板的方式,并重点解析了纸张设置的要点:标准预设纸张(A4/A3等)适用于大多数场景,提供国内常用规格对照表;自定义纸张则需谨慎使用,需注意单位选择和尺寸限制。通过界面标注图和操作步骤示意图,帮助用户掌握正确的设置方法,确保最终出图符合规范要求。文章特别提醒新手要优先使用标准预设纸张,避免常见错误,为后续地图 阅读详情

Transferring Sylla
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 1320 Accepted: 322

Description

After recapturing Sylla, the Company plans to establish a new secure system, a transferring net! The new system is designed as follows:

The Company staff choose N cities around the nation which are connected by "security tunnels" directly or indirectly. Once a week, Sylla is to be transferred to another city through the tunnels. As General ordered, the transferring net must reach a certain security level that there are at least 3 independent paths between any pair of cities a, b. When General says the paths are independent, he means that the paths share only a and b in common.

Given a design of a transferring net, your work is to inspect whether it reaches such security level.

Input

The input consists of several test cases.
For each test case, the first line contains two integers, N ≤ 500 and M ≤ 20000. indicating the number of cities and tunnels.
The following M lines each contains two integers a and b (0 ≤ a, b < N), indicating the city a and city b are connected directly by a tunnel.

The input ends by two zeroes.

Output

For each test case output "YES" if it reaches such security level, "NO" otherwise.

Sample Input

4 6
0 1
0 2
0 3
1 2
1 3
2 3

4 5
0 1
0 2
0 3
1 2
1 3

7 6
0 1
0 2
0 3
1 2
1 3
2 3

0 0

Sample Output

YES
NO
NO
------------

无向图的K连通似乎可以用网络流做,但是不会T^T

枚举删除图中的每个顶点,求图的割点

若有割点-->不是双连通-->加上删除的点不是三连通--->结果为NO

没有割点-->是双连通-->加上删除的点是三连通-->结果为YES

------------

/** head-file **/

#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>

/** define-for **/

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)

/** define-useful **/

#define clr(x,a) memset(x,a,sizeof(x))
#define sz(x) int(x.size())
#define see(x) cerr<<#x<<" "<<x<<endl
#define se(x) cerr<<" "<<x
#define pb push_back
#define mp make_pair

/** test **/

#define Display(A, n, m) {                      \
    REP(i, n){                                  \
        REP(j, m) cout << A[i][j] << " ";       \
        cout << endl;                           \
    }                                           \
}

#define Display_1(A, n, m) {                    \
    REP_1(i, n){                                \
        REP_1(j, m) cout << A[i][j] << " ";     \
        cout << endl;                           \
    }                                           \
}

using namespace std;

/** typedef **/

typedef long long LL;

/** Add - On **/

const int direct4[4][2]={ {0,1},{1,0},{0,-1},{-1,0} };
const int direct8[8][2]={ {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
const int direct3[6][3]={ {1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1} };

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INFF = 1LL << 60;
const double EPS = 1e-9;
const double OO = 1e15;
const double PI = acos(-1.0); //M_PI;
const int maxn=1111;
const int maxm=111111;

bool dead[maxn];
int cutnum;
struct EdgeNode_1{
    int to;
    int w;
    int next;
    bool cut;
};
struct Bcc_Graph{
    int head[maxn];
    EdgeNode_1 edges[maxm];
    int edge,n;
    void init(int n){
        memset(head,-1,sizeof(head));
        this->n=n;
        edge=0;
    }
    void addedge(int u,int v,int c=0){
        edges[edge].cut=0,edges[edge].w=c,edges[edge].to=v,edges[edge].next=head[u],head[u]=edge++;
    }
    //点双连通/割点/桥
    int dfn[maxn],low[maxn],dfs_clock;
    bool iscut[maxn];
    int dfs(int u,int fa){
        int lowu=dfn[u]=++dfs_clock;
        int child=0;
        for (int i=head[u];i!=-1;i=edges[i].next){
            int v=edges[i].to;
            if (v==fa) continue;
            if (dead[v]) continue;
            if (!dfn[v]){
                child++;
                int lowv=dfs(v,u);
                lowu=min(lowu,lowv);
                if (dfn[u]<=lowv){
                    if (!iscut[u]) cutnum++;
                    iscut[u]=true;//割点
                    //cerr<<"u is cut "<<u<<" num="<<cutnum<<endl;
                }
            }
            else if (dfn[v]<dfn[u]){
                lowu=min(lowu,dfn[v]);
            }
        }
        if (fa<0&&child==1){
            if (iscut[u]) cutnum--;
            //cerr<<"u is not cut "<<u<<" num="<<cutnum<<endl;
            iscut[u]=0;//割点
        }
        low[u]=lowu;
        return lowu;
    }
    void find_bcc(){
        memset(dfn,0,sizeof(dfn));
        memset(iscut,0,sizeof(iscut));
        dfs_clock=0;
        bool ok=false;
        for (int i=1;i<=n;i++){
            if (!dfn[i]&&!dead[i]){
                if (ok) {
                    cutnum++;
                    break;
                }
                dfs(i,-1);
                if (cutnum>0) break;
                ok=true;
            }
        }
    }
}solver;

int n,m;
int main()
{
    while (~scanf("%d%d",&n,&m)){
        if (n==0&&m==0) break;
        solver.init(n);
        REP(i,m){
            int x,y;
            scanf("%d%d",&x,&y);
            x++;
            y++;
            solver.addedge(x,y);
            solver.addedge(y,x);
        }
        memset(dead,0,sizeof(dead));
        bool ans=true;
        REP_1(i,n){
            dead[i]=true;
            cutnum=0;
            solver.find_bcc();
            //cerr<<i<<" cut="<<cutnum<<endl;
            if (cutnum>0){
                ans=false;
                break;
            }
            dead[i]=false;
        }
        if (ans) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}




2025华为OD面试手撕代码真题目录及面试八股文 本专栏更新每年华为OD机试的高频手撕代码题,每个题目都会使用五种语言进行解答(C & C++& Java & Python & JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2024e卷,od机试,2024E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2024华为od,如何备 阅读详情

相关推荐

Echocardiography Image Segmentation: A Survey(超声心动图图像分割方法综述--中文翻译)

Echocardiography Image Segmentation: A Survey 摘要:尽管超声图像的获取是较廉价,并且免于辐射的,但是超声图像因为信号衰减、斑点噪声等干扰,使得超声图像的分割具有较大挑战。本文将近些年应用于超声心动图像分割的相关方法进行了分类总结,并列出了10篇具有原创思想的文章,这些文章具有特殊的临床使用价值或是对于超声心动图像分割具有指导意义。 关键词:超声心动...

mrj4124的博客 5105

POJ 3713 Transferring Sylla 已翻译

<span title="Description ">描述 在夺回Sylla后,公司计划建立一个新的安全系统,一个转移网!<span title="The new system is designed as follows: ">新系统设计如下: 公司员工选择全国各地直接或间接通过“安全隧道”连接的N个城市。每周一次,Sylla将通过隧道转移到另一个城市。按照Gener

woniupengpeng的专栏 553

保姆级教程:用Python+Mediapipe实时捕捉手势,驱动Unity虚拟手模型(附完整源码)

本文详细介绍了如何利用Python的Mediapipe库和Unity实现实时手势识别与虚拟手模型驱动。通过OpenCV进行图像采集,Mediapipe提供21个手部关键点识别,结合UDP通信协议实现Python与Unity之间的低延迟数据传输。教程包含完整源码、环境配置、核心代码实现及性能优化技巧,适用于VR教育、游戏开发等需要自然交互的场景。

weixin_42531779的博客 363

POJ 3713 Transferring Sylla(强联通分量割点)

Transferring SyllaTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 3203 Accepted: 886DescriptionAfter recapturing Sylla, the Company plans to establish a new secure system, a transferring net...

albertluf的博客 376

深入浅出ISP:用RKISP2.x Tuner工具理解AWB、AE、HDR等核心模块的实战调参

本文深入解析RKISP2.x Tuner工具在ISP图像处理中的实战应用,重点探讨AWB、AE、HDR等核心模块的调参技巧。通过环境搭建、调试工具使用和实际案例,帮助开发者掌握如何在不同光照条件下优化图像质量,实现精准的白平衡、曝光控制和动态范围处理。

weixin_26802933的博客 494

Oracle19c SYSAUX表空间爆满?手把手教你清理SM/ADVISOR和AUDSYS占用(附完整SQL)

本文详细解析了Oracle19c中SYSAUX表空间爆满的常见原因及解决方案,重点针对SM/ADVISOR和AUDSYS组件的空间占用问题提供了完整的SQL清理脚本。通过诊断查询、空间清理和预防性维护策略,帮助DBA有效管理SYSAUX表空间,确保数据库稳定运行。

weixin_28338005的博客 245

POJ-3713-Transferring Sylla

这个题被纳入网络流部分,我开始就直接朝网络流

z309241990的专栏 1602

iOS Certificates, Identifiers & Profiles简介

1. Certificates Certificates是生成开发和生产所需的证书。 2.1 certSigningRequest文件 生成证书前,需要先生成certSigningRequest文件,certSigningRequest文件由【钥匙串访问】生成。 选择菜单【钥匙串访问】,【证书助理】下的【从证书颁发机构请求证书…】 填写【用户电子邮件地址: 】,将【请求是:】的选项改为【储存到磁盘】 输入certSigningRequest文件的文件名,并指定保存位置。 保存certSignin

假装你是大灰狼的专栏 7065

POJ - 3713 (Transferring Sylla)

题意:给定一个 n 个顶点 和 m 条边的无向图(可能不连通),问是否满足每两个点之间都有至少三条不同的路径; 分析:枚举所有的点,删去当前点并判断剩下的图存不存在割点,若存在则表明剩下的图存在两个点只能通过割点这一条路径,就算加上删去的点也至多有两条不同的路径,不满足题意; 代码: #include<cstdio> #include<cstring> ...

Joker & Liar的博客 249

手把手教你用分立元件搭建自举电路:解决高端MOS驱动难题

本文详细介绍了如何用分立元件搭建自举电路,解决高端MOS驱动中的栅源极电压不足问题。通过面包板实验,逐步讲解二极管、电容等关键元件的选型与电路搭建,提供波形调试和常见问题排查方法,帮助工程师提升开关电源和电机驱动等应用的效率与可靠性。

weixin_30555125的博客 159

量产导入 | 产品可靠性测试标准完整大集合(JEDEC/IEC/SAE…)

产品可靠性测试是产品质量保证中的重要一环, 包含有Pre-con, aging(寿命)和ESD(静电)等, 下面就收集了权威标准JEDEC全系列, 请参照如下 同时也附上其它的可靠性标准供大家参考及交叉理解, 可能侧重点不同, 大家可以参考下。

叫好与叫座虽然不是对立面,但想在同一个作品中达到双重效果很难。 1675

poj 3713 图的三连通

//图的三连通的判断 //在图中删去一个点,判断是否存在割点,以及判断图是否连通 #include #include #include using namespace std; const int MAX = 1010; vector edge[MAX]; int low[MAX],dfn[MAX]; int vis[MAX]; int n,m,tdfn; bool flag

努力奋斗才能梦想成真 1282

RT-DETR改进策略【损失函数篇】| 通过辅助边界框计算IoU提升检测效果(Inner_GIoU、Inner_DIoU、Inner_CIoU、Inner_EIoU、Inner_SIoU)

为了弥补现有 IoU 损失在不同检测任务中泛化性弱和收敛速度慢的问题,·Inner-IoU·通过引入比例因子 “ratio” 来控制辅助边界框的尺度大小,利用不同尺度的辅助边界框来计算损失,从而加速边界框回归过程。

Limiiiing的博客 1972

poj 3713 Transferring Sylla 判断无向图是否每两个点之间都能至少有3点不同的路径可达 是否3-连通

After recapturing Sylla, the Company plans to establish a new secure system, a transferring net! The new system is designed as follows:The C

kongming_acm的专栏 2127

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

efm32 入门.pdf

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

POJ 3713 Transferring Sylla(图的三联通,tarjan算法

http://www.hankcs.com/program/algorithm/poj-3713-transferring-sylla.html 思路和解答可以参考上面这一篇文章,很详细。这个题一开始tle了若干发,结果把临接矩阵换成临接表a了。。。。。。本来图论题有时候就会出现卡常熟的情况,如果不是需要删边删点什么的临接矩阵还是慎用。。。。。。。 #include #include #inc

废弃。。 1174

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

POJ3713: Transferring Sylla 题解

如果任意两个顶点之间都有至少三条没有重复顶点的路径,那么这个图中任意删除两个顶点,一定还是连通的。这是充要条件,非常重要 朴素想法是枚举删除哪两个点,再跑一遍dfs。但这样是O(n*n*m)的,会超时 可以枚举删除那个点,再用tarjan判断有没有割点这样就是O(n*m)的,可以通过 有考虑多网络流的方法 因为任意点都不能重复走两次,然后就考虑拆点,拆成in和out,然后之间连一条流量为1

IcePrincess_1968's World 471

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

poj3713 Transferring Sylla (java实现)

问题描述 给一个N个节点的图,要求任意两个顶点之间至少有3条独立的路径,判断所给的图是否满足该条件。 问题分析 所有点之间都有3条独立的路径就表示点3连通图,如果任意删掉1个点,图仍然是双连通图,那么原图是3连通图。双连通图可以根据tarjan算法判断。 算法实现 import java.io.*; import java.util.Arrays; import static java.lang.Math.min; public class Main { StreamTok

Xp545945的博客 230

Transferring Sylla POJ, 3713

/*本题注意初始化问题*/ 方法见图片 #include #include #include #include #include #define MAXN 505 #define maxn 40005 using  namespace std; int parent[MAXN];//每个节点的父亲 int dfn[MAXN]; int low[MAXN]; typede

ICDI的博客 403

Transferring Sylla POJ - 3713(tarjan)

Transferring Sylla POJ - 3713 After recapturing Sylla, the Company plans to establish a new secure system, a transferring net! The new system is designed as follows:The Company staff choose N cities around the nation which are connected by “security tunnel

rainbowsea_1的博客 180

POJ 3713 Transferring Sylla (三联通分量)

Transferring Sylla Time Limit:5000MS Memory Limit:65536K Total Submissions:3533 Accepted:988 Description After recapturing Sylla, the Company plans to establish...

weixin_30670925的博客 186

POJ3713-Transferring Sylla

Transferring Sylla Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2906   Accepted: 802 Description After recapturing Sylla, the Company plans to establish

wang_128的博客 418

POJ 3713 Transferring Sylla (三连通图)

【题目链接】http://poj.org/problem?id=3713 【题目大意】   给出一个图判断是不是三连通图,三连通图的意思是对于图中任意两点,   至少有三条路是可以相互连通的。 【题解】   我们可以枚举一个点去掉,然后判断图中是否存在割点,如果存在,   则说明这不是个三连通分图,否则则说明是三连通分图。 【代码】 #incl...

weixin_30532973的博客 287

POJ,3713 Transferring Sylla

题意:重新夺得Sylla之后,公司决定加强安保系统,就是建个运输网络,General要求这个网络必须满足每两个城市之间至少有三条独立的路线。(越看越像prison break)现在给你城市的坐标,让你判断合不合规定,复核规定就输出YES,不然就输出NO 思路:检查样例是不是三通路,其实就是把每个点去掉以后看看剩下的点有没有割点,如果有割点就是单通路,不符合规定,如果没有割点,就输是正确的。 #

s1054436218的博客 403

POJ 3713 Transferring Sylla​ 题解 《挑战程序设计竞赛》

为什么80%的码农都做不了架构师?>>> ...

weixin_34101784的博客 221

poj3713 Transferring Sylla 枚举+tarjan判割点

题意: 思路:图的三联通判断。

AC_kereo的专栏 1751

[POJ 3713] Transferring Sylla (枚举删点+Tarjan求割点)

POJ - 3713 给定一张 N个点的无向图,问是否三联通 三联通指的是从a到b有三条除了a和b外没有重点的路径 暴力的做法是枚举删掉两个点,看图是否还联通 复杂度 (N3)\mathcal{O}(N^3) 但是 N<=500,在POJ上肯定被卡掉了 所以优化的做法是枚举删掉一个点,看图是否有割点 如果存在割点,说明删掉这个点,图就不联通了 复杂度 (N2)\mathcal

MisDeer's blog 635
上一篇: SPOJ 7758 Growing Strings AC自动机DP
下一篇: poj 2987 Firing 最大权闭合图
cyendra
博客等级 码龄14年 191粉丝 462原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值