poj 1144 Network【图的割点】模板

Description

A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N . No two places have the same number. The lines are bidirectional and always connect together two places and in each place the lines end in a telephone exchange. There is one telephone exchange in each place. From each place it is 
possible to reach through lines every other place, however it need not be a direct connection, it can go through several exchanges. From time to time the power supply fails at a place and then the exchange does not operate. The officials from TLC realized that in such a case it can happen that besides the fact that the place with the failure is unreachable, this can also cause that some other places cannot connect to each other. In such a case we will say the place (where the failure 
occured) is critical. Now the officials are trying to write a program for finding the number of all such critical places. Help them.

Input

The input file consists of several blocks of lines. Each block describes one network. In the first line of each block there is the number of places N < 100. Each of the next at most N lines contains the number of a place followed by the numbers of some places to which there is a direct line from this place. These at most N lines completely describe the network, i.e., each direct connection of two places in the network is contained at least in one row. All numbers in one line are separated 
by one space. Each block ends with a line containing just 0. The last block has only one line with N = 0;

Output

The output contains for each block except the last in the input file one line containing the number of critical places.

Sample Input

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

Sample Output

1
2
  • 代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define LL long long
#define INF 99999999
using namespace std;
const int maxn=1005;
int flag[maxn];
int num[maxn],low[maxn];
int e[105][105];
int cnt,index;
int root;
int n;
void dfs(int cur,int father){
    int child=0;
    index++;
    num[cur]=index;
    low[cur]=index;
    for(int i=1;i<=n;i++){
        if(e[cur][i]){
            if(!num[i]){
                child++;
                dfs(i,cur);
                low[cur]=min(low[cur],low[i]);
                if(cur!=root&&low[i]>=num[cur]){
                    flag[cur]=1;
                }
                if(cur==root&&child>=2){
                    flag[cur]=1;
                }
            }else if(i!=father){
                low[cur]=min(low[cur],num[i]);
            }
        }
    }
}
int main(){
    while(scanf("%d",&n)&&n){
        cnt=0;
        index=0;
        int u,v;
        memset(flag,0,sizeof flag);
        memset(num,0,sizeof num);
        memset(low,0,sizeof low);
        memset(e,0,sizeof e);
        while(scanf("%d",&u)&&u){
            while(getchar()!='\n'){
                scanf("%d",&v);
                e[u][v]=e[v][u]=1;
            }
        }
        root=1;
        dfs(1,root);
        for(int i=1;i<=n;i++){
            if(flag[i]) cnt++;
                //printf("%d ",i);
        }
        printf("%d\n",cnt);
    }
    return 0;
}

图的割点模板:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
const int maxn=1005;
int e[maxn][maxn];
int flag[maxn],num[maxn],low[maxn];
int n,m,index;
int root;
void dfs(int cur,int father){//当前顶点编号和父节点编号
    int child=0;
    index++;//时间戳加1
    num[cur]=index;//当前顶点的时间戳
    low[cur]=index;//当前顶点cur能够访问到最早顶点的时间戳
    for(int i=1;i<=n;i++){
        if(e[cur][i]){
            if(!num[i]){//时间戳为,说明当前顶点还没有被访问过
                child++;
                dfs(i,cur);
                low[cur]=min(low[cur],low[i]);//更新当前顶点能够访问到的最小时间戳
                if(cur!=root&&low[i]>=num[cur]){//如果当前顶点不是根节点并且满足low[i]>=num[cur],则当前顶点为割点
                    flag[cur]=1;
                }
                if(cur==root&&child==2){//如果是根节点且有两个以上孩子,则当前顶点为割点。
                    flag[cur]=1;
                }
            }else if(i!=father){
            //否则如果当前顶点i曾经被访问过,
            //并且这个顶点不是当前当前顶点cur的父亲,则需要更新当前节点cur
            //能否访问到最早顶点的时间戳
                low[cur]=min(low[cur],num[i]);
            }
        }
    }
}
int main()
{
    int a,b;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            e[i][j]=0;
        }
    }
    for(int i=1;i<=m;i++){
        scanf("%d %d",&a,&b);
        e[a][b]=e[b][a]=1;
    }
    root=1;
    dfs(1,root);
    for(int i=1;i<=n;i++){
        if(flag[i]) printf("%d ",i);
    }
    printf("\n");
    /*for(int i=1;i<=n;i++){
        printf("%d ",low[i]);
    }
    printf("\n");
    for(int i=1;i<=n;i++){
        printf("%d ",num[i]);
    }
    printf("\n");*/
    return 0;
}

/*
6 7
1 4
1 3
4 2
3 2
2 5
2 6
5 6
*/

### 关于ArcGIS License Server无法启动的解决方案 当遇到ArcGIS License Server无法启动的情况时,可以从以下几个方面排查并解决问题: #### 1. **检查网络配置** 确保License Server所在的计算机能够被其他客户端正常访问。如果是在局域网环境中部署了ArcGIS Server Local,则需要确认该环境下的网络设置是否允许远程连接AO组件[^1]。 #### 2. **验证服务状态** 检查ArcGIS Server Object Manager (SOM) 的运行情况。通常情况下,在Host SOM机器上需将此服务更改为由本地系统账户登录,并重启相关服务来恢复其正常工作流程[^2]。 #### 3. **审查日志文件** 查看ArcGIS License Manager的日志记录,寻找任何可能指示错误原因的信息。这些日志可以帮助识别具体是什么阻止了许可证服务器的成功初始化。 #### 4. **权限问题** 确认用于启动ArcGIS License Server的服务账号具有足够的权限执行所需操作。这包括但不限于读取/写入特定目录的权利以及与其他必要进程通信的能力。 #### 5. **软件版本兼容性** 保证所使用的ArcGIS产品及其依赖项之间存在良好的版本匹配度。不一致可能会导致意外行为或完全失败激活license server的功能。 #### 示例代码片段:修改服务登录身份 以下是更改Windows服务登录凭据的一个简单PowerShell脚本例子: ```powershell $serviceName = "ArcGISServerObjectManager" $newUsername = ".\LocalSystemUser" # 替换为实际用户名 $newPassword = ConvertTo-SecureString "" -AsPlainText -Force Set-Service -Name $serviceName -StartupType Automatic New-ServiceCredential -ServiceName $serviceName -Account $newUsername -Password $newPassword Restart-Service -Name $serviceName ``` 上述脚本仅作为示范用途,请依据实际情况调整参数值后再实施。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值