CSU 1249 Competitive enzyme inhibitors and isozymes

Source: Internet
Author: User

1249: Competitive enzyme inhibitors and isozymes

Time limit:1 Sec Memory limit:128 MB
submit:109 solved:49

DescriptionMany chemical reactions in the human body require enzymes to catalyze. The function of enzymes can be simply understood as: converting one substance (substrate) into another (target product). competitive enzyme inhibitors and substrate competition enzyme binding site, when the inhibitor reached a certain dose, the substrate will compete with inhibitors, difficult to bind with enzymes, so that the reaction can not be carried out. enzymes with different structures but catalyze the same chemical reaction are called a group of Isozymes. Usually an inhibitor can inhibit only one enzyme. When an enzyme is suppressed by its inhibitor, the reaction can be continued by the catalysis of the isoenzyme. If a group of isozymes is suppressed, the reaction naturally cannot be carried out. However, the response of the human body is changeable, a reaction pathway is blocked, but also through other reaction pathways, so that the substrate through multi-step transformation, and ultimately into the target product. now that the transition between the various substances is known and the inhibitor dose required to suppress each enzyme, how many doses of the inhibitor is needed at least to completely block the conversion between the two substances?

Inputmultiple sets of test data. For each set of test data:The first line is two integers: N, M, respectively, indicating the number of substances, the number of enzymes (2<=n<=150) (0<=m<=5000). n substances are numbered 1 to n, respectively. Next m line, each line describes an enzyme. A row has three integers a, B, C, indicating that the enzyme can convert a substance to B substance; to inhibit this enzyme, a corresponding inhibitor of C g (0<=c<=100000) is required. Of these m enzymes, there are many isozymes, isoenzyme not more than 250 groups. the last line, two integers s, d, means to completely block S-matter from being converted to D.

Output

Each set of test data outputs a row. The minimum amount of inhibitor required.

Sample Input
5 62 1 23 5 12 3 71 5 33 4 44 5 52 53 41 3 72 3 51 3 61 2 31 33 21 2 21 3 42 3150 01 150
Sample Output
71600
HINT Source

CSU Monthly APR.

Problem solving: It is clear that the minimum cut

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <climits>7#include <vector>8#include <queue>9#include <cstdlib>Ten#include <string> One#include <Set> A#include <stack> - #defineLL Long Long - #definePII pair<int,int> the #defineINF 0x3f3f3f3f - using namespacestd; - Const intMAXN = -; - structarc{ +     intTo,flow,next; -Arcintx =0,inty =0,intz =-1){ +to =x; AFlow =y; atNext =Z; -     } - }; -Arc e[maxn<<3]; - intHEAD[MAXN],D[MAXN],CUR[MAXN]; - inttot,s,t,n,m; in voidAddintUintVintflow) { -E[tot] =arc (V,flow,head[u]); toHead[u] = tot++; +E[tot] = arc (U,0, Head[v]); -HEAD[V] = tot++; the } * BOOLBFs () { $queue<int>Q;Panax Notoginsengmemset (d,-1,sizeof(d)); -D[T] =1; the Q.push (T); +      while(!Q.empty ()) { A         intU =Q.front (); the Q.pop (); +          for(inti = Head[u]; ~i; i =E[i].next) { -             if(e[i^1].flow && d[e[i].to] = =-1){ $D[e[i].to] = D[u] +1; $ Q.push (e[i].to); -             } -         } the     } -     returnD[s] >-1;Wuyi } the intDfsintUintLow ) { -     if(U = = T)returnLow ; Wu     intTMP =0, A; -      for(int&i = Cur[u]; ~i; i =E[i].next) { About         if(E[i].flow && d[e[i].to]+1==d[u]&& (a=Dfs (E[i].to,min (e[i].flow,low)))) { $E[i].flow-=A; -e[i^1].flow + =A; -Low-=A; -TMP + =A; A             if(!tmp) Break; +         } the     } -     if(!tmp) D[u] =-1; $     returntmp; the } the intDinic () { the     intAns =0; the      while(BFS ()) { -memcpy (Cur,head,sizeof(head)); inAns + =DFS (s,inf); the     } the     returnans; About } the intMain () { the     intu,v,w; the      while(~SCANF ("%d%d",&n,&m)) { +memset (head,-1,sizeof(head)); -          for(inti = tot =0; I < m; ++i) { thescanf" %d%d%d",&u,&v,&W);Bayi Add (u,v,w); the         } thescanf"%d%d",&s,&T); -printf"%d\n", Dinic ()); -     } the     return 0; the}
View Code

CSU 1249 Competitive enzyme inhibitors and isozymes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.