program ditch;
type int=cardinal;
bool=boolean;
var c:array[0..200,0..200] of int;
h,vh:array[0..200] of int;
n,augc,rd1,rd2,m,i:int;
flow:int=0;
found:bool;
procedure aug(const m:int);
var i,augco,minh:int;
begin
minh:=n-1;
augco:=augc;
if m=n then
begin
found:=true;
inc(flow,augc);
exit;
end;
for i:=1 to n do
if c[m,i]>0 then
begin
if h+1=h[m] then
begin
if c[m,i]=n then exit;
if found then break;
augc:=augco;
end;
if hend;
if not found then
begin
dec(vh[h[m]]);
if vh[h[m]]=0 then h[1]:=n;
h[m]:=minh+1;
inc(vh[h[m]]);
endelse begin
dec(c[m,i],augc);
inc(c[i,m],augc);
end;
end;
begin
readln(m,n);
fillchar(c,sizeof(c),0);
for i:=1 to m do
begin
readln(rd1,rd2,augc);
inc(c[rd1,rd2],augc);
end;
fillchar(h,sizeof(h),0);
fillchar(vh,sizeof(vh),0);
vh[0]:=n;
while h[1]begin
augc:=$ffffffff;
found:=false;
aug(1);
end;
writeln(flow);
end.
KNN演算法的封裝
knn演算法的封裝 import numpy as np from math import sqrt from collections import counter 定義分類knn函式 defknn classify k,x tarin,y train,x 斷言判斷使用者引數傳入是否正確 asser...
ArrayList集合儲存VO封裝物件後呼叫的問題
vo public class vo4blog public void setb id int b id public int getb typeid public void setb typeid int b typeid public string getb title public void ...
django封裝搜尋後的分頁切換連線
封裝的分頁功能 page.py usr bin env python coding utf 8 time 2020 6 7 18 38 author eunice import refrom django.utils.safestring import mark safe class mypagen...