电商网站开发fd,网址大全12345,php yaf 网站开发框架,wordpress溢价主题正题
评测记录:https://www.luogu.org/recordnew/lists?uid52918pidP3701 题目大意
给出若干个人的克制关系 给出两边每个人的种类和血量。当两个人pkpkpk后#xff0c;双方各−1hp-1hp−1hp#xff0c;同一边的YYYYYYYYY可以给每个同一方的J1hpJ\ 1hpJ 1hp#xf…正题
评测记录:https://www.luogu.org/recordnew/lists?uid52918pidP3701 题目大意
给出若干个人的克制关系 给出两边每个人的种类和血量。当两个人pkpkpk后双方各−1hp-1hp−1hp同一边的YYYYYYYYY可以给每个同一方的J1hpJ\ 1hpJ 1hp血量为0时就不能pkpkpk了两个人之间不能重复pkpkpk。每次选两个人出来比赛比赛mmm轮求第一方最多能赢多少次。 解题思路
因为pk多次我们考虑网络流。 每次pk作为一个流量。 然后一个人能pk x(算上YYY给J的1hp)次的话就用原点连这个点一条x的边。另一个边的就连汇点然后可以击败就连一条1的边。 如样例 3 3 J W YYY J HK E 2 2 2 2 2 2 图的情况 codecodecode
#includecstdio
#includecstring
#includealgorithm
#define N 2100
using namespace std;
struct line{int to,next,w;
}a[N*10];
struct player{char id[5];
}p[N],p2[N];
int n,m,x,y,d[N],tot2,state[N],hp;
int head,tail,ls[N],s,e,ans,w,YYY1,YYY2;
void addl(int x,int y,int w)//建边
{a[tot].toy;a[tot].nextls[x];a[tot].ww;ls[x]tot;a[tot].tox;a[tot].nextls[y];a[tot].w0;ls[y]tot;
}
bool bfs()
{head0;tail1;memset(d,-1,sizeof(d));d[s]0;state[1]s;do{head;int xstate[head];for (int qls[x];q;qa[q].next){int ya[q].to;if (a[q].w0 d[y]-1){d[y]d[x]1;state[tail]y;if (ye) return true;}}}while (headtail);return false;
}
int dinic(int x,int flow)
{int rest0,k;if (xe) return flow;for (int qls[x];q;qa[q].next){int ya[q].to;if (a[q].w0 d[y]d[x]1){rest(kdinic(y,min(a[q].w,flow-rest)));a[q].w-k;a[q^1].wk;}}if (!rest) d[x]0;return rest;
}
int main()
{scanf(%d%d,n,m);en*22;sn*21;for(int i1;in;i) {scanf(%s,p[i].id);if(p[i].id[0]Y) YYY1;}for(int i1;in;i){scanf(%s,p2[i].id);if(p2[i].id[0]Y) YYY2;}//以上为读入和记录YYY的个数for(int i1;in;i){scanf(%d,hp);if(p[i].id[0]J) addl(s,i,hpYYY1);else addl(s,i,hp);}for(int i1;in;i){scanf(%d,hp);if(p2[i].id[0]J) addl(in,e,hpYYY2);else addl(in,e,hp);}//以上为输入hp和主席特盘for(int i1;in;i){for(int j1;jn;j){char s1p[i].id[0],s2p2[j].id[0];if(s1E(s2J||s2Y)) addl(i,jn,1);if(s1Y(s2J||s2H)) addl(i,jn,1);if(s1H(s2E||s2W)) addl(i,jn,1);if(s1W(s2Y||s2E)) addl(i,jn,1);if(s1J(s2H||s2W)) addl(i,jn,1);}}//击败连边while (bfs())ansdinic(s,1e9);if(ansm) printf(%d,m);//对于m的特判else printf(%d,ans);
}