锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品日本,亚洲午夜久久久,欧美成人免费在线视频http://www.shnenglu.com/lvlawliet/articles/158402.htmlLLawlietLLawlietSat, 15 Oct 2011 14:20:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158402.htmlhttp://www.shnenglu.com/lvlawliet/comments/158402.htmlhttp://www.shnenglu.com/lvlawliet/articles/158402.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158402.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158402.html
2726 Plan
FJ has two same house for rant. Now he has n (1 ≤ n ≤ 1000) piece of order, the orders are 
given in the form: 
s t v
means that someone want to rant a house from the day s to t paying v yuan totally (including 
the day s and t, 0 ≤ s ≤ t ≤ 400, 0 ≤ v ≤ 100,0000). 
A hours can be only rant to one person, and FJ should either accept an order totally or reject it. 
Input
The first line of input file is a single integer T - The number of test cases. For each test case, 
the first line is a single integer n then there n lines, each line gives an order
Output
For each data set, print a single line containing an integer, the maximum total income for the 
data set
Sample Input
3
4
1 2 10
2 3 10
3 3 10
1 3 10
6
1 20 1000
3 25 10000
5 15 5000
22 300 5500
10 295 9000
7 7 6000
8
32 251 2261
123 281 1339
211 235 5641
162 217 72736
22 139 7851
194 198 9190
119 274 878
122 173 8640
Sample Output
30
25500
38595



鍞愮墰鏄ュ緗戠粶嫻佷笓鍦虹殑涓閬撻錛屼粖澶╁仛浜嗕竴涓嬨?br />鍙戠幇鏈灝忚垂鐢ㄦ祦灝辮兘鎼炲畾錛屽畾涔夊畬鏁扮粍鍙戠幇濡傛灉浠rder涓虹偣鑲畾瓚呮椂浜嗭紝鎵浠e鐪嬩簡涓涓嬮錛屽彂鐜皌鐨勮寖鍥村緢灝忥紝閮芥槸鏁存暟錛屾墍浠ユ灉鏂敼鍥撅紝鎶婃瘡縐掍綔涓虹偣灝監K浜嗐?br />寤哄浘鏂規硶錛氱浉閭諱袱涓偣錛坱錛宼 + 1錛夎繛綰匡紝嫻侀噺鏄?錛岃垂鐢ㄦ槸0錛屽浜庢瘡涓涓猳rder錛宻 + 1鍜宼 + 2榪炵嚎錛坱 + 2澶氬姞1鏄洜涓洪槻姝㈡湁璧峰鐐逛笌瀹冪浉鍚岋紝鍑虹幇嫻侀敊璇級嫻侀噺涓?錛岃垂鐢ㄤ負-c錛屽湪榪欎釜鍥句笂鍋氫竴杈規渶灝忚垂鐢ㄦ祦灝辮浜嗐?br />SPFA寰堢妧鍒╋紝涓嶈繃鏋侀檺鏁版嵁榪樻槸璺戜笉榪?.00s.....
浠g爜錛?br />
#include <cstdio>
#include 
<cstring>
#define min(a, b) (a > b ? b : a)
using namespace std;

const int maxn = 405;
const int maxm = 3300;
const int inf = 1 << 30;
int n;

struct Edge
{
    
int v, next, c, w;
} edge[maxm];

int head[maxn], cnt;

void add_edge(int u, int v, int w, int c)
{
    edge[cnt].v 
= v;
    edge[cnt].w 
= w;
    edge[cnt].c 
= c;
    edge[cnt].next 
= head[u];
    head[u] 
= cnt++;

    edge[cnt].v 
= u;
    edge[cnt].w 
= 0;
    edge[cnt].c 
= -c;
    edge[cnt].next 
= head[v];
    head[v] 
= cnt++;
}

int dis[maxn], pre[maxn];
int alpha[maxn];
int que[maxn], qhead, qrear;

int spfa(int s, int e)
{
    
for (int i = 0; i < maxn; ++i)
        dis[i] 
= inf;
    memset(alpha, 
0sizeof(alpha));
    dis[s] 
= 0;
    que[qhead 
= 0= s;
    qrear 
= 1;
    alpha[s] 
= 1;
    
while (qhead != qrear)
    {
        
int k = que[qhead++];
        qhead 
%= maxn;
        alpha[k] 
= 0;
        
for (int q = head[k]; ~q; q = edge[q].next)
            
if (edge[q].w)
                
if (dis[k] + edge[q].c < dis[edge[q].v])
                {
                    dis[edge[q].v] 
= dis[k] + edge[q].c;
                    pre[edge[q].v] 
= q;
                    
if (!alpha[edge[q].v])
                    {
                        alpha[edge[q].v] 
= true;
                        
if (edge[q].c < 0)
                        {
                            qhead 
= (qhead - 1 + maxn) % maxn;
                            que[qhead] 
= edge[q].v;
                        }
                        
else
                        {
                            que[qrear
++= edge[q].v;
                            qrear 
%= maxn;
                        }
                    }
                }
    }
    
if (dis[e] == inf) return -1;
    
int k = inf;
    
for (int i = e; i != s; i = edge[pre[i] ^ 1].v)
       k 
= min(k, edge[pre[i]].w);
    
return k;
}

int mcmf(int s, int t)
{
    
int ans = 0, k;
    
while (~(k = spfa(s, t)))
    {
        
for (int i = t; i != s; i = edge[pre[i] ^ 1].v)
        {
            edge[pre[i]].w 
-= k;
            edge[pre[i] 
^ 1].w += k;
        }
        ans 
+= dis[t] * k;
    }
    
return ans;
}

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

int main()
{
    
int T;
    scanf(
"%d"&T);
    
while (T--)
    {
        init();
        scanf(
"%d"&n);
        
for (int i = 0; i < n; ++i)
        {
            
int a, b, c;
            scanf(
"%d%d%d"&a, &b, &c);
            add_edge(a 
+ 1, b + 21-c);
        }
        
for (int i = 0; i <= 401++i)
            add_edge(i, i 
+ 120);
        
int ans = mcmf(0402);
        printf(
"%d\n"-ans);
    }
}


LLawliet 2011-10-15 22:20 鍙戣〃璇勮
]]>
HDU2934錛欸argoylehttp://www.shnenglu.com/lvlawliet/articles/158395.htmlLLawlietLLawlietSat, 15 Oct 2011 14:16:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158395.htmlhttp://www.shnenglu.com/lvlawliet/comments/158395.htmlhttp://www.shnenglu.com/lvlawliet/articles/158395.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158395.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158395.html

Gargoyle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 139    Accepted Submission(s): 22


Problem Description
Gargoyles can trace their history back many thousands of years to ancient Egypt, Greece, and Rome. Terra cotta waterspouts were formed in the shapes of animals such as lions and birds to serve the physical function of running the
rainwater away from the walls and foundations of buildings, and the spiritual function of protecting from evil forces.
Have you ever dreamed of creating your own castle with a lot of beautiful gargoyles on the walls? To your knowledge,
the speed of water coming out of each gargoyle should be identical, so an elaborately designed water system is required.
The water system consists of a huge reservoir and several interconnecting water pipes. Pipes cannot save water, so the total incoming and outgoing speed of water should be equal at each connection.
All the water from gargoyles flows into the reservoir, which is located at the bottom of the castle. Some pipes are connecting the reservoir, but water can only go from the reservoir to pipes, but never from pipes back to the reservoir. A micro-processor is installed inside each pipe, so the speed of water could easily be controlled. However, the microprocessors consume electricity. The exact cost in each pipe is proportional to the speed of water. If the cost constant in the i-th pipe is ci, the electricity cost in that pipe is civi, where vi is the speed of water in that pipe. Write a program to find the optimal configuration of the water system (i.e. the water speed in each pipe) of your dream castle, so that the total cost is minimized. It is always possible to build a water system.
 

Input
The input consists of several test cases. The first line of each case contains three integers n, m and k (1 ≤ n ≤ 25, 1 ≤ m ≤ 50, 1 ≤ k ≤ 1000), the number of gargoyles, the number of pipe connections and the number of pipes. The following k lines each contains five integers a, b, l, u, c (0 ≤ a, b ≤ n + m, 0 ≤ l ≤ u ≤ 100, 1 ≤ c ≤ 100), describing each pipe. a and b
are the incoming and outgoing vertex number (reservoir is 0, gargoyles are numbered 1 to n, pipe connections are numbered n + 1 to n + m), lower-bound and upper-bound of water speed, and the cost constant. No pipe connects two identical vertices. For every pipe, the incoming vertex will never be a gargoyle, and the outgoing vertex will never be the reservoir. For every pair of vertices, there could be at most one pipe connecting them (if a pipe is going from a to b, no pipes can go from a to b, or from b to a). The last test case is followed by a single zero, which should not be processed.
 

Output
For each test case, print the case number and minimal cost to two decimal places.
 

Sample Input
3 1 4 0 4 8 15 5 4 1 2 5 2 4 2 1 6 1 4 3 3 7 2 0
 

Sample Output
Case 1: 60.00
 

Source
 

Recommend
lcy
 




06騫翠簹媧插尯鍩熻禌瑗垮畨璧涘尯鐨勪竴閬撶綉緇滄祦錛岀浉褰撶妧鍒?.....鎴慦A寰堜箙寰堜箙鎵嶅媺寮鴻繃浜?......

涓錛庢諱綋鍒嗘瀽
鏈緇欏嚭浜嗕竴涓綉緇滄祦鐨勬ā鍨嬨備互縐按姹犱負婧愮偣錛屾瘡涓繛鎺ョ偣鍜屽柗姘村彛涓虹粨鐐癸紝鍙﹀寤虹珛涓涓秴綰ф眹錛屾瘡涓柗姘村彛鍚戣秴綰ф眹榪炰竴鏉¤竟銆傞鐩氨鏄眰涓涓湁涓婁笅鐣岀殑鏈灝忚垂鐢ㄦ祦錛屽叾涓埌姹囩偣鐨勬瘡涓鏉¤竟鐨勬祦閲忓繀欏葷浉絳?*)銆?/div>
寰堝鏂囩尞瀵規湁涓婁笅鐣岀殑璐圭敤嫻佽繘琛屼簡璁ㄨ錛屾湰鏂囦笉鍐嶈禈榪般傛湰鏂囦富瑕佽璁鴻В鍐沖浣曡В鍐?*)鐨勮姹傘?br />
浜岋紟鍒ゆ柇鍙嫻?/div>
鎴戜滑涓嶅Θ璁炬墍鏈夎繛鎺ュ埌姹囩偣鐨勮竟鐨勬祦閲忓潎涓篎錛屾垜浠鍋氱殑絎竴姝ュ氨鏄細鍒ゆ柇鏄惁瀛樺湪榪欐牱涓緇勫彲琛屾祦浣垮緱F = F0鎴愮珛銆?/div>
鎴戜滑涓嶅Θ緇欐瘡涓鏉¤繛鎺ュ埌姹囩偣鐨勮竟寤虹珛涓婁笅鐣孾0錛孎0]銆傛垜浠粰鍑轟互涓嬪紩鐞嗭細
寮曠悊涓錛氬瓨鍦ㄦ弧瓚充嬌寰桭0鐨勫彲琛屾祦錛屽綋涓斾粎褰撹緗戠粶鐨勬渶澶ф祦涓篎0N銆?/div>
寮曠悊浜岋細鑻ユ渶澶ф祦灝忎簬F0N錛屽垯涓嶅瓨鍦‵ >= F0鐨勫彲琛屾祦錛?/div>
寮曠悊涓夛細鑻ヤ笉瀛樺湪鍙嫻侊紝鍒欎笉瀛樺湪F <= F0鐨勫彲琛屾祦錛?/div>

鐢卞紩鐞嗕簩銆佷笁鍙煡錛?/div>
寮曠悊鍥涳細
瀛樺湪鍙嫻佺殑F鐨勫畾涔夊煙涓轟竴孌佃繛緇殑鍖洪棿[low, top]銆?/div>
鏍規嵁寮曠悊浜屻佷笁鍜屽洓錛屾垜浠笉闅句嬌鐢ㄤ簩鍒嗘硶鎵懼嚭榪欎竴孌礔鐨勫彲琛屽尯闂碵low, top]銆?/div>

涓夛紟鎵懼嚭鏈灝忚垂鐢ㄦ祦
璁癱ost(F)琛ㄧず鍦‵鎴愮珛鐨勬渶灝忚垂鐢ㄣ傛垜浠寽嫻嬶紝cost(F)涓嶧鎴愭姣旓紒
鎰熻涓婏紝F瓚婂ぇ錛屾祦閲忚秺澶э紝閭d箞姣忔潯杈逛笂娑堣楃殑璐圭敤涔熷氨瓚婂ぇ錛屾墍浠ョ寽鎯沖簲璇ユ垚绔嬨傚彲鎯滅殑鏄紝鎸夌収璇ユ兂娉曟彁浜ゆ槸鏃犳硶閫氳繃嫻嬭瘯鏁版嵁鐨勩傚洜涓猴細

澶у涓嶅厤鐤戦棶錛屽崟璋冨嚱鏁頒笉涔熸槸鍑哥殑涔堬紵
娉ㄦ剰鍒版湁涓婁笅鐣岀殑鏈灝忚垂鐢ㄧ敱涓ら儴鍒嗘瀯鎴愶細闄勫姞緗戠粶鐨勬渶灝忚垂鐢ㄥ強孌嬩綑緗戠粶鐨勬渶灝忚垂鐢ㄣ傛敞鎰忓埌鍓嶈呮槸鍏充簬F涓嶅鐨勫悗鑰呮槸鍏充簬F涓嶅噺鐨勶紝濡傛灉鍓嶈呯殑閫掑噺閫熷害澶т簬鍚庤呯殑閫掑閫熷害錛岄偅涔坈ost(F)灝嗘垚涓轟笅鍑稿嚱鏁般?/div>

鍥涳紟綆楁硶嫻佺▼

鐢變簬鏈灝忚垂鐢ㄦ祦鐨勬椂闂村鏉傚害涓嶅ソ鍒嗘瀽錛屾湰鏂囩洿鎺ヨ涓烘槸O(kN2)錛屽叾涓璳琛ㄧず澧炲箍嬈℃暟錛岀畻娉曟葷殑鏃墮棿澶嶆潅搴︿負O(kN2logC)銆?/div>


LLawliet 2011-10-15 22:16 鍙戣〃璇勮
]]>POJ1149:PIGShttp://www.shnenglu.com/lvlawliet/articles/158386.htmlLLawlietLLawlietSat, 15 Oct 2011 14:12:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158386.htmlhttp://www.shnenglu.com/lvlawliet/comments/158386.htmlhttp://www.shnenglu.com/lvlawliet/articles/158386.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158386.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158386.html
PIGS
Time Limit: 1000MSMemory Limit: 10000K
Total Submissions: 10566Accepted: 4622

Description

Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys to some pig-houses and wants to buy a certain number of pigs. 
All data concerning customers planning to visit the farm on that particular day are available to Mirko early in the morning so that he can make a sales-plan in order to maximize the number of pigs sold. 
More precisely, the procedure is as following: the customer arives, opens all pig-houses to which he has the key, Mirko sells a certain number of pigs from all the unlocked pig-houses to him, and, if Mirko wants, he can redistribute the remaining pigs across the unlocked pig-houses. 
An unlimited number of pigs can be placed in every pig-house. 
Write a program that will find the maximum number of pigs that he can sell on that day.

Input

The first line of input contains two integers M and N, 1 <= M <= 1000, 1 <= N <= 100, number of pighouses and number of customers. Pig houses are numbered from 1 to M and customers are numbered from 1 to N. 
The next line contains M integeres, for each pig-house initial number of pigs. The number of pigs in each pig-house is greater or equal to 0 and less or equal to 1000. 
The next N lines contains records about the customers in the following form ( record about the i-th customer is written in the (i+2)-th line): 
A K1 K2 ... KA B It means that this customer has key to the pig-houses marked with the numbers K1, K2, ..., KA (sorted nondecreasingly ) and that he wants to buy B pigs. Numbers A and B can be equal to 0.

Output

The first and only line of the output should contain the number of sold pigs.

Sample Input

3 3
3 1 10
2 1 2 2
2 1 3 3
1 2 6

Sample Output

7


鏈澶ф祦錛屾瀯鍥炬濇兂錛氱敤浜哄綋鐐癸紝鍥犱負姣忎釜浜烘槸鎸夐『搴忕殑錛屾墍浠ョi涓漢絎竴嬈℃墦寮絎琸涓尓鍦堬紝絎琷涓漢絎簩嬈℃墦寮絎琸涓尓鍦堟椂錛岀浉褰撲簬絎琲涓漢鍚戠j涓漢澧炴祦銆?br />鎵浠ワ紝濡傛灉絎琲涓漢鎸佹湁絎琸涓尓鍦堢殑閽ュ寵錛屽鏋滄槸絎竴嬈℃墦寮錛屽氨浠庢簮鐐瑰紩杈瑰悜璇ョ偣錛岃竟鏉冪瘡鍔犵尓鍦堢殑鍊鹼紙涓涓漢鍙兘鎸佹湁澶氫釜閽ュ寵錛屾墍浠ヨ绱姞錛夛紝濡傛灉涓嶆槸絎竴嬈★紝閭d箞浠庝笂涓嬈¢偅涓漢寮曞嚭涓鏉℃棤闄愬ぇ鐨勮竟鍒癷鐐逛綔涓哄嫻併傛瘡涓偣鍒版眹鐐圭殑鏉冨兼槸璇ヤ漢闇瑕佺殑涓暟錛屾渶澶ф祦涓嬈″氨琛屼簡銆?br />SAP錛屾椂闂村緢濂界湅銆?br />浠g爜錛?/div>
#include<stdio.h>
#include<string.h>
#include
<iostream>
#include
<queue>
#define N 1010
using namespace std;
const int maxnode=60000;
const int maxedge=320000;
const int  inf = 1 << 30;
int S,T,cnt,n,m;
int head[maxnode],gap[maxnode],pre[maxnode],cur[maxnode],dis[maxnode];
struct Edge
{
    
int S,t;
    
int next;
    
int w;
}st[maxedge];
void init()
{
    memset(head,
-1,sizeof(head));
    cnt
=0;
}
void AddEdge(int S,int t,int w)
{
    st[cnt].S
=S;
    st[cnt].t
=t;
    st[cnt].w
=w;
    st[cnt].next
=head[S];
    head[S]
=cnt;
    cnt
++;
    st[cnt].S
=t;
    st[cnt].t
=S;
    st[cnt].w
=0;
    st[cnt].next
=head[t];
    head[t]
=cnt;
    cnt
++;
}
void bfs()
{
    memset(gap,
0,sizeof(gap));
    memset(dis,
-1,sizeof(dis));
    queue
<int >Q;
    Q.push(T);
    dis[T]
=0;
    gap[
0]=1;
    
int k,t;
    
while(!Q.empty())
    {
        k
=Q.front();
        Q.pop();
        
for(int i=head[k];i!=-1;i=st[i].next)
        {
            t
=st[i].t;
            
if(dis[t]==-1&&st[i^1].w>0)
            {
                dis[t]
=dis[k]+1;
                gap[dis[t]]
++;
                Q.push(t);
            }
        }
    }
}
int sap()
{
    
int i;
    
for( i=S;i<=T;i++)cur[i]=head[i];
    pre[S]
=S;
    
int u=S,v;
    
int  flow=0;
    
int aug=inf;
    
bool flag;
    
while(dis[S]<=T)
    {
        flag
=false;
        
for( i=cur[u];i!=-1;i=st[i].next)
        {
            v
=st[i].t;
            
if(st[i].w>0&&dis[u]==dis[v]+1)
            {
                cur[u]
=i;
                flag
=true;
                pre[v]
=u;
                aug
=(aug>st[i].w)?st[i].w:aug;
                u
=v;
                
if(v==T)
                {
                    flow
+=aug;
                    
for(u=pre[u];v!=S;u=pre[u])
                    {
                        v
=u;
                        st[cur[u]].w
-=aug;
                        st[cur[u]
^1].w+=aug;
                    }
                    aug
=inf;
                }
                
break;
            }
        }
        
if(flag==true)continue;
        
int mint=T;
        
for( i=head[u];i!=-1;i=st[i].next)
        {
            v
=st[i].t;
            
if(st[i].w>0&&mint>dis[v])
            {
                cur[u]
=i;
                mint
=dis[v];
            }
        }
        gap[dis[u]]
--;
        
if(gap[dis[u]]==0)break;
        gap[dis[u]
=mint+1]++;
        u
=pre[u];
        
if(u==S)aug=inf;
    }
    
return flow;
}

int main()
{
    
int map[N][N];
    
int num[N];
    
int f[N];
    
while (scanf("%d%d"&m, &n) != EOF)
    {
        memset(map, 
0sizeof(map));
        memset(f, 
0sizeof(f));
        init();
        S 
= 0;
        T 
= n + 1;
        
for (int i = 1; i <= m; ++i)
            scanf(
"%d"&num[i]);
        
for (int i = 1; i <= n; ++i)
        {
            
int a, b;
            scanf(
"%d"&a);
            
for (int j = 1; j <= a; ++j)
            {
                
int x;
                scanf(
"%d"&x);
                
if (f[x] == 0)
                {
                    map[S][i] 
+= num[x];
                    f[x] 
= i;
                }
                
else
                {
                    map[f[x]][i] 
= inf;
                    f[x] 
= i;
                }
            }
            scanf(
"%d"&b);
            map[i][T] 
+= b;
        }
        
for (int i = S; i <= T; ++i)
            
for (int j = S; j <= T; ++j)
            
if (map[i][j])
            {
                
//printf("%d %d %d\n", i, j, map[i][j]);
                AddEdge(i, j, map[i][j]);
            }
        bfs();
        printf(
"%d\n", sap());
    }
}

/*
4 2
1 2 3 5
3 1 2 3 10
1 4 5

*/


LLawliet 2011-10-15 22:12 鍙戣〃璇勮
]]>HDU3879:Base Stationhttp://www.shnenglu.com/lvlawliet/articles/158384.htmlLLawlietLLawlietSat, 15 Oct 2011 14:10:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158384.htmlhttp://www.shnenglu.com/lvlawliet/comments/158384.htmlhttp://www.shnenglu.com/lvlawliet/articles/158384.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158384.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158384.html

Base Station

Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 65768/32768 K (Java/Others)
Total Submission(s): 844    Accepted Submission(s): 353


Problem Description
A famous mobile communication company is planning to build a new set of base stations. According to the previous investigation, n places are chosen as the possible new locations to build those new stations. However, the condition of each position varies much, so the costs to built a station at different places are different. The cost to build a new station at the ith place is Pi (1<=i<=n).

When complete building, two places which both have stations can communicate with each other.

Besides, according to the marketing department, the company has received m requirements. The ith requirement is represented by three integers Ai, Bi and Ci, which means if place Aand Bi can communicate with each other, the company will get Ci profit.

Now, the company wants to maximize the profits, so maybe just part of the possible locations will be chosen to build new stations. The boss wants to know the maximum profits.
 

Input
Multiple test cases (no more than 20), for each test case:
The first line has two integers n (0<n<=5000) and m (0<m<=50000).
The second line has n integers, P1 through Pn, describes the cost of each location.
Next m line, each line contains three integers, Ai, Bi and Ci, describes the ith requirement.
 

Output
One integer each case, the maximum profit of the company.
 

Sample Input
5 5 1 2 3 4 5 1 2 3 2 3 4 1 3 3 1 4 2 4 5 3
 

Sample Output
4
 

Author
liulibo
 

Source
 

Recommend
lcy
 
璁烘枃棰橈紝Amber鏈灝忓壊妯″瀷閲岄潰鐨勶紝鏈澶ф潈闂悎鍥撅紝鍥犱負鏁扮粍寮鐨勫お澶т簡錛屽悆浜嗕竴嬈E......
鏈澶ф潈闂悎鍥句笉鐢ㄨ浜嗭紝杈圭湅鎴愭敹鐩婄偣錛岃繛鍚慡錛屾祦閲忔槸鐐規潈錛岀珯鐐圭湅鎴愯姳璐圭偣錛岃繛鍚慣錛屾祦閲忎篃鏄偣鏉冿紝鍏朵粬鎸夌収鍘熷浘榪炶竟錛屾祦閲忔槸鏃犻檺澶э紝涔嬪悗鍋氫竴嬈℃渶灝忓壊錛屽壊鍊煎氨鏄綘鏈夌殑鏀剁泭鐐?閫夊畾鑺辮垂鐐癸紙鍥犱負鏄棴鍚堝浘錛屾墍浠ュ壊鑲畾鏄畝鍗曞壊錛屾兂涓涓嬪壊鐨勫畾涔夛紝灝辨槑鐧藉壊鍊肩殑鍚箟浜嗭級錛岀敤浣犳繪敹鐩?鍓插鹼紝灝辨槸絳旀銆?br />鐢⊿AP姹傜殑鏈灝忓壊錛屾笎娓愮埍涓奡AP浜嗭紝Dinic涓嶇敤浜?....
浠g爜錛?br />
#include <cstdio>
#include 
<cstring>
#include 
<iostream>
#include 
<queue>
using namespace std;

const int maxnode = 60000;
const int maxedge = 320000;
const long long inf = (1LL << 35);

int S, T, cnt;
int head[maxnode], gap[maxnode], pre[maxnode], cur[maxnode], dis[maxnode];

struct Edge
{
    
int s, t;
    
int next;
    
long long w;
} st[maxedge];

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

void AddEdge(int s, int t, long long w)
{
    st[cnt].s 
= s;
    st[cnt].t 
= t;
    st[cnt].w 
= w;
    st[cnt].next 
= head[s];
    head[s] 
= cnt;
    cnt
++;

    st[cnt].s 
= t;
    st[cnt].t 
= s;
    st[cnt].w 
= 0;
    st[cnt].next 
= head[t];
    head[t] 
= cnt;
    cnt
++;
}

void bfs()
{
    memset(gap, 
0sizeof(gap));
    memset(dis, 
-1sizeof(dis));
    queue 
<int> Q;
    Q.push(T);
    dis[T] 
= 0;
    gap[
0= 1;
    
int k, t;
    
while (!Q.empty())
    {
        k 
= Q.front();
        Q.pop();
        
for (int i = head[k]; i != -1; i =st[i].next)
        {
            t 
= st[i].t;
            
if (dis[t] == -1 && st[i ^ 1].w > 0)
            {
                dis[t] 
= dis[k] + 1;
                gap[dis[t]]
++;
                Q.push(t);
            }
        }
    }
}

long long sap()
{
    
int i;
    
for (i = S; i <= T; ++i)
        cur[i] 
= head[i];
    pre[S] 
= S;
    
int u = S, v;
    
long long flow = 0;
    
long long aug = inf;
    
bool flag;
    
while (dis[S] <= T)
    {
        flag 
= false;
        
for (i = cur[u]; i != -1; i = st[i].next)
        {
            v 
= st[i].t;
            
if (st[i].w > 0 && dis[u] == dis[v] + 1)
            {
                cur[u] 
= i;
                flag 
= true;
                pre[v] 
= u;
                aug 
= (aug > st[i].w) ? st[i].w : aug;
                u 
= v;
                
if (v == T)
                {
                    flow 
+= aug;
                    
for (u = pre[u]; v != S; u = pre[u])
                    {
                        v 
= u;
                        st[cur[u]].w 
-= aug;
                        st[cur[u] 
^ 1].w += aug;
                    }
                    aug 
= inf;
                }
                
break;
            }
        }
        
if (flag == truecontinue;
        
int mint = T;
        
for (i = head[u]; i != -1; i = st[i].next)
        {
            v 
= st[i].t;
            
if (st[i].w > 0 && mint > dis[v])
            {
                cur[u] 
= i;
                mint 
= dis[v];
            }
        }
        gap[dis[u]]
--;
        
if (gap[dis[u]] == 0break;
        gap[dis[u] 
= mint + 1]++;
        u 
= pre[u];
        
if (u == S) aug = inf;
    }
    
return flow;
}

int main()
{
    
int n, m;
    
while (scanf("%d%d"&n, &m) != EOF)
    {
        init();
        S 
= 0;
        T 
= n + m + 1;
        
int sum = 0;
        
for (int i = 1; i <= n; ++i)
        {
            
int x;
            scanf(
"%d"&x);
            AddEdge(m 
+ i, T, x);
        }
        
for (int i = 1; i <= m; ++i)
        {
            
int a, b, c;
            scanf(
"%d%d%d"&a, &b, &c);
            AddEdge(S, i, c);
            AddEdge(i, m 
+ a, inf);
            AddEdge(i, m 
+ b, inf);
            sum 
+= c;
        }
        bfs();
        sum 
-= sap();
        printf(
"%d\n", sum);
    }
    
return 0;
}


LLawliet 2011-10-15 22:10 鍙戣〃璇勮
]]>POJ2914:Minimum Cuthttp://www.shnenglu.com/lvlawliet/articles/158385.htmlLLawlietLLawlietSat, 15 Oct 2011 14:10:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158385.htmlhttp://www.shnenglu.com/lvlawliet/comments/158385.htmlhttp://www.shnenglu.com/lvlawliet/articles/158385.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158385.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158385.html
Minimum Cut
Time Limit: 10000MSMemory Limit: 65536K
Total Submissions: 5403Accepted: 2113
Case Time Limit: 5000MS

Description

Given an undirected graph, in which two vertices can be connected by multiple edges, what is the size of the minimum cut of the graph? i.e. how many edges must be removed at least to disconnect the graph into two subgraphs?

Input

Input contains multiple test cases. Each test case starts with two integers N and M (2 ≤ N ≤ 500, 0 ≤ M ≤ N × (N − 1) ⁄ 2) in one line, where N is the number of vertices. Following are M lines, each line contains M integers AB and C (0 ≤ AB < NA ≠ BC > 0), meaning that there C edges connecting vertices A and B.

Output

There is only one line for each test case, which contains the size of the minimum cut of the graph. If the graph is disconnected, print 0.

Sample Input

3 3
0 1 1
1 2 1
2 0 1
4 3
0 1 1
1 2 1
2 3 1
8 14
0 1 1
0 2 1
0 3 1
1 2 1
1 3 1
2 3 1
4 5 1
4 6 1
4 7 1
5 6 1
5 7 1
6 7 1
4 0 1
7 3 1

Sample Output

2
1
2

Source

Baidu Star 2006 Semifinal 
Wang, Ying (Originator) 
Chen, Shixi (Test cases)

鍏ㄥ眬鏈灝忓壊錛屾ā鏉塊錛孲tor-Wagner綆楁硶錛屽ぇ姒傚氨鏄痯rime鐨勬渶澶х敓鎴愭爲錛屽叿浣撶殑緗戜笂鏈夊緢澶氾紝鍙互google鍒扮殑錛屼笉澶氳浜嗐?br />浠g爜錛?/div>
#include<stdio.h>
#include<string.h>

#define NN 504
#define INF 1 << 30
int vis[NN];
int wet[NN];
int combine[NN];
int map[NN][NN];

int S, T, minCut, N;
void Search()
{
    
int i, j, Max, tmp;
    memset(vis, 
0sizeof(vis));
    memset(wet, 
0sizeof(wet));
    S 
= T = -1;
    
for (i = 0; i < N; i++)
    {
        Max 
= -INF;
        
for (j = 0; j < N; j++)
        {
            
if (!combine[j] && !vis[j] && wet[j] > Max)
            {
                tmp 
= j;
                Max 
= wet[j];
            }
        }
        
if (T == tmp) return;
        S 
= T;
        T 
= tmp;
        minCut 
= Max;
        vis[tmp] 
= 1;
        
for (j = 0; j < N; j++)
        {
            
if (!combine[j] && !vis[j])
            {
                wet[j] 
+= map[tmp][j];
            }
        }
    }
}
int Stoer_Wagner()
{
    
int i, j;
    memset(combine, 
0sizeof(combine));
    
int ans = INF;
    
for (i = 0; i < N - 1; i++)
    {
        Search();
        
if (minCut < ans) ans = minCut;
        
if (ans == 0return 0;
        combine[T] 
= 1;
        
for (j = 0; j < N; j++)
        {
            
if (!combine[j])
            {
                map[S][j] 
+= map[T][j];
                map[j][S] 
+= map[j][T];
            }
        }
    }
    
return ans;
}
int main()
{
    
int a, b, c, M;
    
while(scanf("%d%d"&N, &M) != EOF)
    {
        memset(map, 
0sizeof(map));
        
while(M--)
        {
            scanf(
"%d%d%d"&a, &b, &c);
            map[a][b] 
+= c;
            map[b][a] 
+= c;
        }
        printf(
"%d\n", Stoer_Wagner());
    }
    
return 0;
}


LLawliet 2011-10-15 22:10 鍙戣〃璇勮
]]>
POJ2125:Destroying The Graphhttp://www.shnenglu.com/lvlawliet/articles/158383.htmlLLawlietLLawlietSat, 15 Oct 2011 14:09:00 GMThttp://www.shnenglu.com/lvlawliet/articles/158383.htmlhttp://www.shnenglu.com/lvlawliet/comments/158383.htmlhttp://www.shnenglu.com/lvlawliet/articles/158383.html#Feedback0http://www.shnenglu.com/lvlawliet/comments/commentRss/158383.htmlhttp://www.shnenglu.com/lvlawliet/services/trackbacks/158383.html
Destroying The Graph
Time Limit: 2000MSMemory Limit: 65536K
Total Submissions: 4718Accepted: 1436Special Judge

Description

Alice and Bob play the following game. First, Alice draws some directed graph with N vertices and M arcs. After that Bob tries to destroy it. In a move he may take any vertex of the graph and remove either all arcs incoming into this vertex, or all arcs outgoing from this vertex. 
Alice assigns two costs to each vertex: Wi+ and Wi-. If Bob removes all arcs incoming into the i-th vertex he pays Wi+ dollars to Alice, and if he removes outgoing arcs he pays Wi- dollars. 
Find out what minimal sum Bob needs to remove all arcs from the graph.

Input

Input file describes the graph Alice has drawn. The first line of the input file contains N and M (1 <= N <= 100, 1 <= M <= 5000). The second line contains N integer numbers specifying Wi+. The third line defines Wi- in a similar way. All costs are positive and do not exceed 106 . Each of the following M lines contains two integers describing the corresponding arc of the graph. Graph may contain loops and parallel arcs.

Output

On the first line of the output file print W --- the minimal sum Bob must have to remove all arcs from the graph. On the second line print K --- the number of moves Bob needs to do it. After that print K lines that describe Bob's moves. Each line must first contain the number of the vertex and then '+' or '-' character, separated by one space. Character '+' means that Bob removes all arcs incoming into the specified vertex and '-' that Bob removes all arcs outgoing from the specified vertex.

Sample Input

3 6
1 2 3
4 2 1
1 2
1 1
3 2
1 2
3 1
2 3

Sample Output

5
3
1 +
2 -
2 +

Source

Northeastern Europe 2003, Northern Subregion



涓閬撳吀鍨嬬殑鏈灝忕偣鏉冭鐩栭棶棰橈紝SAP閫熷害寰堝ソ鐪嬶紝涔嬪悗闇瑕佹悳绱竴涓嬬敤榪囩殑鐐癸紝杈撳嚭鍗沖彲銆?br />浠g爜錛?br />
#include <iostream>
#include 
<cstdio>
#include 
<cstring>
#include 
<cmath>
#define N 10010
#define M 20010
#define inf 1 << 30
#define eps 1 << 29
using namespace std;

int mark[N];
int cnt, n, m, s, t;
int head[N];
int NN;

struct edge
{
    
int v, next, w;
} edge[M];

void addedge(int u, int v, int w)
{
    edge[cnt].v 
= v;
    edge[cnt].w 
= w;
    edge[cnt].next 
= head[u];
    head[u] 
= cnt++;
    edge[cnt].v 
= u;
    edge[cnt].w 
= 0;
    edge[cnt].next 
= head[v];
    head[v] 
= cnt++;
}

int sap()
{
    
int pre[N], cur[N], dis[N], gap[N];
    
int flow = 0, aug = inf, u;
    
bool flag;
    
for (int i = 1; i <= NN; ++i)
    {
        cur[i] 
= head[i];
        gap[i] 
= dis[i] = 0;
    }
    gap[s] 
= NN;
    u 
= pre[s] = s;
    
while (dis[s] < NN)
    {
        flag 
= 0;
        
for (int &= cur[u]; j != -1; j = edge[j].next)
        {
            
int v = edge[j].v;
            
if (edge[j].w > 0 && dis[u] == dis[v] + 1)
            {
                flag 
= 1;
                
if (edge[j].w < aug) aug = edge[j].w;
                pre[v] 
= u;
                u 
= v;
                
if (u == t)
                {
                    flow 
+= aug;
                    
while (u != s)
                    {
                        u 
= pre[u];
                        edge[cur[u]].w 
-= aug;
                        edge[cur[u] 
^ 1].w += aug;
                    }
                    aug 
= inf;
                }
                
break;
            }
        }
        
if (flag)
            
continue;
        
int mindis = NN;
        
for (int j = head[u]; j != -1; j = edge[j].next)
        {
            
int v = edge[j].v;
            
if (edge[j].w > 0 && dis[v] < mindis)
            {
                mindis 
= dis[v];
                cur[u] 
= j;
            }
        }
        
if ((--gap[dis[u]]) == 0)
            
break;
        gap[dis[u] 
= mindis + 1]++;
        u 
= pre[u];
    }
    
return flow;
}

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

void dfs(int x)      //涓嶅悓浜庡崟綰殑SAP錛屽姞鍏ヤ簡涓涓悳绱犵偣闆嗗厓绱犵殑鍑芥暟錛岄氳繃head鏁扮粍鐨勮褰曚俊鎭悳绱€?br />{
    mark[x] 
= 1;
    
for (int i = head[x]; i; i = edge[i].next)
    {
        
if (edge[i].w > 0 && !mark[edge[i].v]) dfs(edge[i].v);
    }
}

int main()
{
    
while (scanf("%d%d"&n, &m) != EOF)
    {
        init();
        
int wp[101], wm[101], w, len = 1, ans[105];
        s 
= 0;
        t 
= 2 * n + 1;
        NN 
= 2 * n + 2;
        
for (int i = 1; i <= n; ++i)
        {
            scanf(
"%d"&wp[i]);
            addedge(i 
+ n, t, wp[i]);
        }
        
for (int i = 1; i <= n; ++i)
        {
            scanf(
"%d"&wm[i]);
            addedge(s, i, wm[i]);
        }
        
for (int i = 1; i <= m; ++i)
        {
            
int x, y;
            scanf(
"%d%d"&x, &y);
            addedge(x, y 
+ n, inf);
        };
        w 
= sap();
        dfs(s);
        
for (int i = 1; i <= n; ++i)
        {
            
if (!mark[i]) ans[len++= i;
            
if (mark[i + n]) ans[len++= i + n;
        }
        len
--;
        printf(
"%d\n%d\n", w, len);
        
for (int i = 1; i <= len; ++i)
        {
            
if (ans[i] <=n) printf("%d -\n", ans[i]);
            
else printf("%d +\n", ans[i] - n);
        }
    }
    
return 0;
}



LLawliet 2011-10-15 22:09 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              亚洲欧美日韩精品久久| 欧美日韩在线免费观看| 久久野战av| 1000部精品久久久久久久久| 久久一本综合频道| 亚洲欧洲在线视频| 亚洲一区二区三区精品视频| 国产乱码精品| 老司机精品福利视频| 亚洲精品国产精品乱码不99按摩 | 国产精品美女主播在线观看纯欲| 亚洲一区精彩视频| 欧美sm重口味系列视频在线观看| aa级大片欧美| 国产亚洲精品久久久久动| 美女网站久久| 亚洲一区www| 蜜桃伊人久久| 香蕉视频成人在线观看| 精品999网站| 欧美三级乱码| 美女免费视频一区| 亚洲一区二区三区乱码aⅴ蜜桃女| 久久亚洲综合网| 亚洲一级网站| 亚洲国产老妈| 国产欧美一区二区三区沐欲| 久久一区精品| 亚洲欧美日韩精品久久久久| 欧美大秀在线观看| 欧美中文在线观看| 亚洲精品一区二区三区99| 国产欧美日韩不卡免费| 欧美国产视频在线| 久久精品人人做人人综合| 日韩一区二区精品葵司在线| 欧美jjzz| 久久视频在线视频| 午夜免费电影一区在线观看| 99在线精品视频| 亚洲国产成人精品久久久国产成人一区| 欧美日韩另类视频| 欧美69wwwcom| 久久久久久成人| 亚洲欧美精品| 亚洲一区二区三区乱码aⅴ蜜桃女| 欧美激情一区二区三区四区| 久久久视频精品| 久久电影一区| 午夜精品久久一牛影视| 一区二区免费在线观看| 亚洲开发第一视频在线播放| 曰韩精品一区二区| 很黄很黄激情成人| 国产一区二区三区免费不卡 | 久久久久久夜| 欧美一区深夜视频| 午夜精品久久| 亚洲欧美视频在线| 亚洲欧美在线免费观看| 亚洲在线视频免费观看| 一区二区高清在线观看| 99在线|亚洲一区二区| 亚洲毛片一区二区| 亚洲精品在线二区| 99热在线精品观看| 一区二区三区免费在线观看| 亚洲激情二区| 亚洲区在线播放| 最近中文字幕日韩精品| 在线播放中文一区| 18成人免费观看视频| 伊人久久成人| 亚洲日本黄色| 亚洲美女黄色片| 一区二区高清| 午夜精彩国产免费不卡不顿大片| 亚洲网站在线观看| 午夜精品一区二区三区在线视 | 欧美在线播放一区| 久久久久国产精品www| 久久久久久亚洲精品杨幂换脸| 久久久免费av| 欧美国产综合一区二区| 亚洲精品字幕| 亚洲在线观看视频网站| 午夜一区在线| 久久久亚洲欧洲日产国码αv | 亚洲亚洲精品三区日韩精品在线视频| 一区二区三区久久| 亚洲免费网址| 久久精品在线播放| 欧美高潮视频| 99re6这里只有精品视频在线观看| 99re亚洲国产精品| 亚洲欧美综合国产精品一区| 久久精品av麻豆的观看方式 | 欧美日韩亚洲一区二区三区四区| 欧美日韩在线播放三区四区| 国产精品免费一区豆花| 精品99一区二区三区| 日韩视频免费观看高清完整版| 亚洲欧美日韩直播| 理论片一区二区在线| 亚洲三级影片| 欧美在线网址| 欧美精品在线一区| 国产欧美精品在线播放| 亚洲精品欧美极品| 欧美一区二区播放| 亚洲国产精品嫩草影院| 亚洲综合成人婷婷小说| 久久综合久久88| 国产美女一区二区| 亚洲欧洲一区二区在线观看 | 中文久久乱码一区二区| 久久精品国产96久久久香蕉| 欧美日本高清| 黄色国产精品| 午夜精品免费| 亚洲国产日韩欧美在线动漫| 亚洲欧美在线一区| 欧美激情视频网站| 国产一区二区0| 亚洲图片欧美午夜| 亚洲国产va精品久久久不卡综合| 亚洲欧美国产日韩天堂区| 欧美精品福利在线| 国内精品久久久久久久果冻传媒| 这里是久久伊人| 欧美激情亚洲一区| 久久久久99精品国产片| 国产精品久久久久久影院8一贰佰| 亚洲激情成人网| 久久综合网络一区二区| 亚洲欧美中文日韩在线| 欧美日韩国产一区二区三区地区| 影音先锋日韩资源| 久久久久一区二区三区四区| 99在线精品观看| 欧美久久婷婷综合色| 亚洲国产1区| 美日韩丰满少妇在线观看| 亚洲欧美日韩另类| 国产精品三上| 亚洲主播在线播放| 一本色道久久综合亚洲精品不 | 欧美日韩精品三区| 亚洲精品九九| 欧美国产日韩精品| 麻豆av一区二区三区久久| 影音先锋欧美精品| 免费成人在线观看视频| 久久精品国产精品| 韩日欧美一区| 久久影视三级福利片| 久久av二区| 国产一区欧美| 久久这里有精品15一区二区三区| 欧美一二区视频| 国产综合色产在线精品| 久久男人av资源网站| 欧美综合国产| 18成人免费观看视频| 欧美大片一区二区| 欧美丰满高潮xxxx喷水动漫| 亚洲精品无人区| 日韩视频久久| 国产精品卡一卡二| 久久爱www| 久久婷婷综合激情| 亚洲韩国一区二区三区| 亚洲国产日韩一区二区| 欧美精品尤物在线| 亚洲私人影吧| 午夜精品久久久久久久白皮肤| 国产一区二区三区高清在线观看| 久久影院亚洲| 欧美成人有码| 亚洲自拍偷拍视频| 久久激情视频免费观看| 亚洲成人资源| 亚洲韩国精品一区| 欧美偷拍一区二区| 欧美在线免费播放| 美日韩在线观看| 亚洲色图自拍| 久久精品卡一| 一区二区三区 在线观看视频| 在线亚洲+欧美+日本专区| 国产亚洲激情| 亚洲国产美女精品久久久久∴| 欧美日本三级| 久久在线免费| 欧美日本国产在线| 久久riav二区三区| 欧美高清视频在线播放| 欧美一区二区成人6969| 免费日韩成人| 欧美在线观看视频一区二区三区 |