Brexit Negotiations(Kattis-Northwestern Europe Regional Contest (NWERC) 2018)

Problem Description

As we all know, Brexit negotiations are on their way—but we still do not know whether they will actually finish in time.

The negotiations will take place topic-by-topic. To organise the negotiations in the most effective way, the topics will all be discussed and finalised in separate meetings, one meeting at a time.

This system exists partly because there are (non-cyclic) dependencies between some topics: for example, one cannot have a meaningful talk about tariffs before deciding upon the customs union. The EU can decide on any order in which to negotiate the topics, as long as the mentioned dependencies are respected and all topics are covered.

Each of the topics will be discussed at length using every available piece of data, including key results from past meetings. At the start of each meeting, the delegates will take one extra minute for each of the meetings that has already happened by that point, even unrelated ones, to recap the discussions and understand how their conclusions were reached. See Figure 1 for an example.

Nobody likes long meetings. The EU would like you to help order the meetings in a way such that the longest meeting takes as little time as possible.

\includegraphics[width=0.9\textwidth ]{sample1}

Figure 1: Illustration of how time is spent in each meeting in a solution to Sample Input 2.

Input

The input consists of:

One line containing an integer n (1≤n≤4⋅105), the number of topics to be discussed. The topics are numbered from 1 to n.

n lines, describing the negotiation topics.

The ith such line starts with two integers eiei and di (1≤ei≤106, 0≤di<n0≤di<n), the number of minutes needed to reach a conclusion on topic ii and the number of other specific topics that must be dealt with before topic ii can be discussed.

The remainder of the line has didi distinct integers bi,1,…,bi,di (1≤bi,j≤n and bi,j≠i for each j), the list of topics that need to be completed before topic i.

It is guaranteed that there are no cycles in the topic dependencies, and that the sum of didi over all topics is at most 4⋅105.

Output

Output the minimum possible length of the longest of all meetings, if meetings are arranged optimally according to the above rules.

Sample Example

Sample Input 1

3
10 0
10 0
10 0

Sample Output 1

12

Sample Input 2

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

Sample Output 2

8

题意:n 个会议,依次给出每个会议的持续时间、开这个会议前要开的会议编号,在开每个会议前,要回顾当前会议前的所有会议,每个会议回顾 1 个单位时间,问最长会议的最短时间

思路:

直接对 n 个会议的持续时间从小到大排序,从而保证最长的会议再最前,然后对于 n 个会议进行 dfs,在开当前会议 x 之前先对统计其依赖会议,最后输出这 n 个会议中的最大值即可

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 400000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

struct Node {
    int id;
    int time;
    bool operator < (const Node &rhs) {//按会议时间从大到小排序
        return time>rhs.time;
    }
}a[N];
int times[N];
vector<int> G[N];
bool vis[N];
int res=-INF,extra=0;
void dfs(int x) {
    if(vis[x]==true)//第x个点被访问过
        return;

    if(vis[x]==false&&G[x].size()==0) {//第x个点未访问过且其没有依赖节点
        res=max(res,extra+times[x]);//统计最大值
        extra++;//额外时间+1
        vis[x]=true;
        return;
    }

    vis[x]=true;
    for(int i=0; i<G[x].size(); i++)//遍历x的所有依赖节点
        dfs(G[x][i]);

    res=max(res,extra+times[x]);
    extra++;
}
int main() {
    int n;
    while(scanf("%d",&n)!=-1) {
        memset(vis,false,sizeof(vis));
        for(int i=0; i<=n; i++)
            G[i].clear();

        for(int i=1; i<=n; i++) {
            scanf("%d",&a[i].time);
            times[i]=a[i].time;
            a[i].id=i;
            //res=max(times[i],res);
            int num;
            scanf("%d",&num);
            while(num--) {
                int x;
                scanf("%d",&x);
                G[i].push_back(x);
            }
        }

        sort(a+1,a+n+1);

        for(int i=1; i<=n; i++)
            if(vis[a[i].id]==false)
                dfs(a[i].id);

        printf("%d",res);
    }
    return 0;
}

 

### Cisco Port-channel10 配置概述 在思科设备上配置 Port-channel 接口涉及多个步骤,其中包括定义参与聚合的物理端口以及设置通道组模式。以下是关于如何创建和配置 `Port-channel10` 的详细说明。 #### 创建并启用 Port-channel10 为了创建名为 `Port-channel10` 的逻辑接口,需先通过命令行界面(CLI)进入全局配置模式,并执行以下操作: ```bash SW1(config)# interface port-channel 10 ``` 此命令会创建一个新的逻辑以太网信道接口编号为 10[^1]。 #### 将物理接口加入到 Port-channel10 中 要将一组物理接口分配给新创建的 `port-channel10`,可以使用范围指定法来简化过程。例如,如果希望将两个快速以太网接口 (`fa1/13`, `fa1/14`) 添加至该链路聚合,则可按如下方式完成: ```bash SW1(config)# int range fa1/13 - 14 SW1(config-if-range)# channel-group 10 mode ? on Enable EtherChannel only. active LACP - actively negotiate an aggregation by sending and receiving LACPDUs. passive LACP - passively negotiate an aggregation by responding to LACPDUs. desirable PAgP - enable negotiation of an aggregated group using PAgP, send periodic updates. auto PAgP - enable participation in negotiated groups but do not initiate negotiations. ``` 在此上下文中,“mode” 参数决定了这些成员端口之间协商的方式。比如选择 `active` 或者 `passive` 可启动基于 IEEE 标准的 **Link Aggregation Control Protocol (LACP)** 协商机制;而选用 `desirable` 则采用思科专有的 **PAgP** 方法[^2]。 对于本例中的具体实现,假设我们决定利用 LACP 动态协议来进行自动检测与绑定,则应输入: ```bash SW1(config-if-range)# channel-group 10 mode active ``` 这一步骤将在所选物理接口上激活 LACP 并尝试建立连接至远程交换机上的对应 Port-channel10 实体[^4]。 #### 关于TFTP服务器的要求 值得注意的是,在某些情况下,当涉及到从 TFTP 服务器加载软件镜像或其他文件时,运行 Cisco IOS 的设备应当处于同一局域网络(LAN)之中才能成功访问资源[^3]。尽管这一细节主要针对固件升级场景而非常规端口配置流程,但在实际部署过程中仍可能间接影响整体规划决策。 --- ### 示例代码展示完整的配置序列 下面提供了一个完整的 CLI 脚本来演示上述全部步骤: ```bash ! 进入全局配置模式 configure terminal ! 定义新的逻辑以太网信道接口 interface port-channel 10 ! 设置一系列目标物理接口用于组成聚合组 interface range fastethernet 1/13 - 14 ! 启动动态 LACP 模式的端口组合功能 channel-group 10 mode active end write memory ``` 以上脚本展示了如何在一个典型环境中构建起支持冗余性和高带宽传输能力的多链接解决方案——即所谓的 EtherChannel 技术应用实例之一。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值