[CODECHEF]RIN

本文介绍了一种通过最小割算法解决课程安排问题的方法,旨在最大化总得分。考虑到课程的先决条件和学期限制,该算法建立了一个网络流模型来求解最大收益。

题意:一个人要在$m$个学期上$n$节课,在第$j$学期上$i$课有$X_{i,j}$的收益,有些课$B_i$有前置课程$A_i$,问最大得分

这个题我都做不出来还去看题解...我退役吧==

考虑每种课$i$按学期顺序连一条链,容量为$100-X_{i,1}\cdots100-X_{i,m}$(如果一个学期没有这种课就连$+\infty$代表不被割),那么此时$100n-$最小割就是最大收益

为了满足前置课程的要求,对每个要求$A_i,B_i$,我们对$j=1\cdots m$连$((A_i,j),(B_i,j+1),+\infty)$,这样如果$A_i$的第$j$条边被割了,那么$B_i$的前$j$条边一定不会被割,因为每种课只会割一条边

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int inf=2147483647;
int h[10010],nex[50010],to[50010],cap[50010],M=1,S,T;
void ins(int a,int b,int c){
	M++;
	to[M]=b;
	cap[M]=c;
	nex[M]=h[a];
	h[a]=M;
}
void add(int a,int b,int c){
	ins(a,b,c);
	ins(b,a,0);
}
int dis[10010],q[50010];
bool bfs(){
	int head,tail,x,i;
	memset(dis,-1,sizeof(dis));
	head=tail=1;
	q[1]=S;
	dis[S]=0;
	while(head<=tail){
		x=q[head++];
		for(i=h[x];i;i=nex[i]){
			if(cap[i]&&dis[to[i]]==-1){
				dis[to[i]]=dis[x]+1;
				if(to[i]==T)return 1;
				q[++tail]=to[i];
			}
		}
	}
	return 0;
}
int cur[10010];
int dfs(int x,int flow){
	if(x==T)return flow;
	int us=0,i,t;
	for(i=cur[x];i&&flow;i=nex[i]){
		if(cap[i]&&dis[to[i]]==dis[x]+1){
			t=dfs(to[i],min(flow,cap[i]));
			cap[i]-=t;
			cap[i^1]+=t;
			us+=t;
			flow-=t;
			if(cap[i])cur[x]=i;
		}
	}
	if(us==0)dis[x]=-1;
	return us;
}
int dicnic(){
	int ans=0;
	while(bfs()){
		memcpy(cur,h,sizeof(h));
		ans+=dfs(S,inf);
	}
	return ans;
}
int main(){
	int n,m,k,i,j,x,y;
	scanf("%d%d%d",&n,&m,&k);
	S=n*m+1;
	T=n*m+2;
	for(i=1;i<=n;i++){
		add(S,(i-1)*m+1,inf);
		for(j=1;j<=m;j++){
			scanf("%d",&x);
			add((i-1)*m+j,j<m?(i-1)*m+j+1:T,x>=0?100-x:inf);
		}
	}
	while(k--){
		scanf("%d%d",&x,&y);
		for(i=1;i<=m;i++)add((x-1)*m+i,i<m?(y-1)*m+i+1:T,inf);
	}
	printf("%.2lf",(100*n-dicnic())/(double)n);
}

转载于:https://www.cnblogs.com/jefflyy/p/9414413.html

### RIN Issue in MATLAB Relative Intensity Noise (RIN) is a critical parameter that measures the fluctuations of optical power relative to the mean power level over time. In MATLAB, handling and analyzing RIN involves several steps including data acquisition, preprocessing, and analysis techniques. For addressing specific issues related to RIN within MATLAB, one should consider using specialized toolboxes such as Communications Toolbox or RF Blockset which provide functions tailored for signal processing tasks involving noise characteristics[^1]. These toolboxes offer comprehensive tools designed specifically for simulating and measuring various types of noises present in communication systems. Additionally, when interfacing with external simulation environments like Lumerical through APIs, it's important to ensure proper synchronization between different platforms especially regarding variable exchange formats since these variables could include diverse data structures ranging from simple numeric values up to matrices depending on context requirements[^2]. To effectively tackle an RIN issue: - Utilize appropriate built-in functions provided by MATLAB’s Communication System Toolbox. - Ensure accurate conversion and interpretation of exchanged variables while working across multiple software interfaces. ```matlab % Example code snippet demonstrating basic approach towards calculating RIN signalPower = abs(signal).^2; % Calculate instantaneous power meanPower = mean(signalPower); % Compute average power rinValues = (signalPower ./ meanPower) - 1; % Obtain normalized intensity fluctuation stdDeviationOfRin = std(rinValues); % Measure standard deviation indicating severity of RIN ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值