网站域名查主机,网站制作价格行情,网站备案查询怎么查,建站代理平台题意#xff1a;某个学校有m个老师和n个求职者#xff0c;需要讲授s个课程#xff0c;已知每个人的工资c和能交的课程#xff0c;求花费最小使得每门课程都至少有两个人教。 思路#xff1a;状压dp#xff0c;将每个老师要交的课程压缩成一个数#xff0c;然后对于每门课…题意某个学校有m个老师和n个求职者需要讲授s个课程已知每个人的工资c和能交的课程求花费最小使得每门课程都至少有两个人教。 思路状压dp将每个老师要交的课程压缩成一个数然后对于每门课找到每个老师教与不交的最小状态即可。因为INF还被坑了几次 code #include iostream
#include cstdio
#include cmath
#include algorithm
#include cstring
#include sstream
#include string
#include vector
#include list
#include queue
#include stack
#include map
#include set
#include bitsetusing namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF9999999;
const int inf-INF;
const int N125;
const int M2005;
const int mod1000000007;
const double piacos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define ft(i,s,n) for (int is;in;i)
#define lson l,m,rt1
#define rson m1,r,rt1|1
#define lrt rt1
#define rrt rt1|1
#define middle int m(rl)1
#define lowbit(x) (x-x)
#define pii pairint,int
#define mk make_pair
#define IN freopen(in.txt,r,stdin);
#define OUT freopen(out.txt,w,stdout);int n,m,s,c[N],st[N],d[N][18][18];int dp(int i,int s0,int s1,int s2)
{if (imn) { if (s2((1s)-1)) return 0; return INF;}int ansd[i][s1][s2];if (ans0) return ans;ansINF;if (im) ansmin(ans,dp(i1,s0,s1,s2));int mst[i]s0,m1st[i]s1;//s0^m0; s1(s1^m1)|m0;s2|m1;ansmin(ans,c[i]dp(i1,s0^m,(s1^m1)|m,s2|m1));return ans;
}
int main()
{while (~scanf(%d %d %d,s,m,n),s){ft(i,0,nm-1){scanf(%d,c[i]);st[i]0;char chgetchar();while (ch!\n){if (ch1ch9) {int tch-1;st[i](st[i]|(1t));}chgetchar();}//coutst[i]endl;}cls(d,-1);printf(%d\n,dp(0,(1s)-1,0,0));}
}