Uva10480_Sabotage(最小割)

题意:

给定n和m,n表示点的数量,m表示边的数量。
再给m条边(u,v,w)。w表示割该边的花费。注意是无向图,反向边的容量与正向边一致。将结点1看作源点,结点2看作汇点,求一组最小割边集。

思路:

跑最大流。跑完的残余网络中,将源点S能到达的点看作S集,其他点看作T集。如果边的一个点属于S集,另一个点属于T集,那么该边属于最小割边集。

#include <cstdio>
#include <cstring>
#include <algorithm>
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int maxn = 50+5;
const int maxm = 500 + 50;
using namespace std;

int n,m;

// 图 
struct Edge{
    int v, cap, flow, next;
};
Edge edges[maxm*2];
int head[maxn], cnt;

int dis[maxn];    // 分层的编号 
int cur[maxn]; // 当前弧,重要优化!!! 

void init(){
	cnt = 0;
	memset(head, -1, sizeof(head));
}

void addEdge(int u, int v, int cap){
    edges[cnt].v = v; edges[cnt].cap = cap; edges[cnt].flow = 0;
	edges[cnt].next = head[u]; head[u] = cnt++;
	// 反向弧
	edges[cnt].v = u; edges[cnt].cap = cap; edges[cnt].flow = 0;
	edges[cnt].next = head[v]; head[v] = cnt++;
}

// 分层 
int Q[maxn];		// 模拟队列 
bool bfs(int s, int t){
	memset(dis, -1, sizeof(dis));
	dis[s] = 0;
	int front = 0, rear = 0;
	Q[rear++] = s;
	while(front < rear){
		int x = Q[front++];
		if(x == t) return true;
		for(int i = head[x]; i != -1; i = edges[i].next){
			Edge& e = edges[i];
			if(dis[e.v] == -1&&e.cap > e.flow){
				dis[e.v] = dis[x] + 1;
				Q[rear++] = e.v;
			}
		}
	}
	return dis[t] != -1;
}

int dfs(int s, int t, int cur_flow){
    if(s == t||cur_flow == 0) return cur_flow;
    int ans = 0;
    for(int& i = cur[s]; i != -1; i = edges[i].next){
        int c = i;
        Edge e = edges[c];
        if(dis[e.v] == dis[s] + 1&&e.cap > e.flow){
            int a2 = min(cur_flow, e.cap-e.flow);
            int w = dfs(e.v, t, a2);
            edges[c].flow += w;
            edges[c^1].flow -= w; 
            cur_flow -= w;
            ans += w;
            if(cur_flow <= 0) break;
        }
    }
    return ans;
}

// 最大流 
int Dinic(int s, int t){
    int ans = 0;
    while(bfs(s,t)){
        memcpy(cur, head, sizeof(head));
        ans += dfs(s,t,INF);
    }
    return ans;    
}

int vis[maxn];
void find_S(int u){
	vis[u] = 1;
	for(int i = head[u]; i != -1; i = edges[i].next){
		int v = edges[i].v;
		if(vis[v] || edges[i].cap == edges[i].flow) continue;
		find_S(v);
	}
}

int x[maxm], y[maxm];

int main()
{
    //freopen("in.txt","r",stdin);

	while(scanf("%d%d",&n,&m) == 2){
		if(n == 0&&m == 0) break;
		init();
		//for(int i = 1; i <= n; ++i) addEdge(i, i+n, 1);
		for(int i = 0; i < m; ++i){
			int c; scanf("%d%d%d",&x[i],&y[i],&c);
			addEdge(x[i], y[i],c);
		}
		LL c;
		int s = 1, t = 2;
		
		Dinic(s, t);
		
		memset(vis, 0, sizeof(vis));
		find_S(s);
		for(int i = 0; i < m; ++i){
			int u = x[i], v = y[i];
			if((!vis[u]&&vis[v]) || (vis[u]&&!vis[v])) printf("%d %d\n",u,v);
		}printf("\n");
	}
    fclose(stdin);
	return 0;
}


### Bullying Definition and Impact in IT Environment Bullying within any professional setting, including the IT environment, involves repeated negative actions by one or more individuals against another individual with the intent to harm[^1]. In an IT context, this can manifest through various forms such as verbal abuse during meetings, exclusion from important communications, undermining work performance via sabotage of projects, spreading false rumors about colleagues' competence levels, or even cyberbullying using digital platforms. The impacts of bullying in the IT sector are profound. Employees subjected to bullying may experience decreased job satisfaction leading to higher turnover rates among skilled professionals who feel undervalued or unsafe at their workplace. Additionally, there is a significant decline in productivity due to increased stress levels which affect mental health negatively causing anxiety disorders or depression amongst victims. Furthermore, team cohesion suffers when members witness aggressive behaviors towards peers; trust erodes between coworkers resulting in poor collaboration efforts that hinder project success overall. ```python def identify_bullying_behavior(actions): """ A function to determine if given actions constitute bullying behavior. Parameters: actions (list): List of observed behaviors Returns: bool: True if identified as bullying, False otherwise """ indicators = ["verbal abuse", "exclusion", "sabotage", "false rumors"] return any(action.lower() in indicators for action in actions) # Example usage print(identify_bullying_behavior(["Verbal Abuse"])) # Output should be True ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值