由於數據比較水,就打了許多冗餘,也由於這道題比較糾結,也不想再改了,將就看着吧
const maxn=100; max=1073741819; inf='shopping.in'; ouf='shopping.out'; anf='shopping1.out'; var n,m,s2,s:longint; ans1,ans2:real; v,cle:array[0..maxn]of boolean; b,c,b1,c1:array[0..maxn,0..maxn]of longint; cost,cost1:array[0..maxn,0..maxn]of real; st,pre,num,visit,pre1:array[0..maxn]of longint; min:array[0..maxn]of real; function dfs(x:longint;var z:boolean):longint; var i,j,ne,na:longint; cos:real; begin if x=s then begin dfs:=0;exit end; dfs:=0;visit[x]:=1; if visit[pre[x]]=2 then begin visit[x]:=2;exit end; if (visit[pre[x]]=1) then begin dfs:=pre[x];z:=true;cle[x]:=false;v[x]:=false;ans1:=ans1+cost[pre[x],x]; inc(s2);st[s2]:=x;visit[x]:=2;exit end; if visit[pre[x]]=0 then dfs:=dfs(pre[x],z); visit[x]:=2; if dfs=-1 then exit; if dfs=0 then begin{ ans1:=ans1+cost[pre[x],x];cle[x]:=false; }exit end; v[x]:=false; if x<>dfs then begin inc(s2);st[s2]:=x;cle[x]:=false;ans1:=ans1+cost[pre[x],x];exit end; i:=1;ans1:=ans1+cost[pre[x],x];inc(s2);st[s2]:=x; c1:=c;b1:=b;pre1:=pre;cost1:=cost; while i<=s2 do begin ne:=st[i]; for j:=1 to b[ne,0] do if (v[b[ne,j]])and(cle[b[ne,j]]) then begin na:=b[ne,j]; if cost1[x,na]>max then begin inc(b1[x,0]);b1[x,b1[x,0]]:=na;inc(c1[na,0]);c1[na,c1[na,0]]:=x end; if cost[ne,na]<cost1[x,na] then cost1[x,na]:=cost[ne,na]; if (cost[ne,na]<cost1[pre1[na],na])or(not cle[pre1[na]]) then pre1[na]:=x end; for j:=1 to c[ne,0] do if (v[c[ne,j]])and(cle[c[ne,j]]) then begin na:=c[ne,j]; if cost[na,x]>max then begin inc(b1[na,0]);b1[na,b1[na,0]]:=x;inc(c1[x,0]);c1[x,c1[x,0]]:=na end; cos:=cost[na,ne]-cost[pre[ne],ne]; if cos<cost1[na,x] then cost1[na,x]:=cos; if (cos<cost1[pre1[x],x])or(not cle[pre1[x]]) then pre1[x]:=na end; inc(i) end; b:=b1;c:=c1;pre:=pre1;cost:=cost1;dfs:=-1 end; procedure dfs2(x:longint); begin if x=0 then exit; visit[x]:=1; if visit[pre[x]]=0 then dfs2(pre[x]); visit[x]:=2;cle[x]:=false; ans1:=ans1+cost[pre[x],x]; end; procedure getans; var i:longint; begin fillchar(visit,sizeof(visit),0); for i:=1 to n do if (cle[i])and(visit[i]=0) then dfs2(i) end; procedure mintree; var z:boolean; i:longint; begin z:=false; fillchar(visit,sizeof(visit),0); fillchar(v,sizeof(v),true); fillchar(st,sizeof(st),0);s2:=0; for i:=1 to n do if (cle[i])and(visit[i]=0) then if dfs(i,z)<>0 then break; if z then mintree else getans end; procedure origin; var i:longint; begin for i:=1 to n do begin pre[i]:=n+1;cost[pre[i],i]:=max end; fillchar(cle,sizeof(cle),true); fillchar(cost,sizeof(cost),127); ans1:=0;ans2:=0; fillchar(min,sizeof(min),127); fillchar(c,sizeof(c),0);fillchar(b,sizeof(b),0); end; procedure init; var i,x,y:longint; xx,z:real; begin assign(input,inf);reset(input); readln(n); origin; s:=0; for i:=1 to n do begin readln(xx,y); num[i]:=y; if y>0 then begin inc(b[s,0]);b[s,b[s,0]]:=i;cost[s,i]:=xx; inc(c[i,0]);c[i,c[i,0]]:=s; if cost[s,i]<cost[pre[i],i] then pre[i]:=s; if xx<min[i] then min[i]:=xx end else cle[i]:=false end; readln(m); for i:=1 to m do begin readln(x,y,z); if (num[x]>0)and(num[y]>0) then begin inc(b[x,0]);b[x,b[x,0]]:=y;cost[x,y]:=z; inc(c[y,0]);c[y,c[y,0]]:=x; if cost[x,y]<cost[pre[y],y] then pre[y]:=x; if z<min[y] then min[y]:=z end end; for i:=1 to n do if num[i]>0 then ans2:=ans2+(num[i]-1)*min[i]; mintree; assign(output,ouf);rewrite(output); writeln(ans1+ans2:0:2); close(output); close(input) end; begin init end.
一、前言 用ffmpeg做音視頻保存到mp4文件,都會遇到一個問題,尤其是在視頻監控行業,就是監控攝像頭設置的音頻是PCM/G711A/G711U,解碼後對應的格式是pcm_s16be/pcm_alaw/pcm_mulaw,將這個原始的音頻
今天看discuz源碼,在一個函數裏發現這麼個語句: http:// $output && print($ret); 其中$output是這個函數的一個參數,值爲true或false;$ret是一個字符串. 測試了一下,如果$output
cvCloneImage()每次使用時編譯器會分配新的內存空間,不會覆蓋以前的內容,所以如果在循環中使用內存會迅速減小,每次用完都需要用cvRelease來釋放。解決方法是使用cvCopy函數代替。cvCopy(pSrcImg,pImg,
關於UCS-2編碼就不多說了,Google一下就大把大把的了 直接上代碼 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> .386 .model flat , stdcall option
本文分享自華爲雲社區《GaussDB SQL基本語法示例-CASE表達式》,作者:Gauss松鼠會小助手2。 一、前言 SQL是用於訪問和處理數據庫的標準計算機語言。GaussDB支持SQL標準(默認支持SQL2、SQL3和SQL4的主要
step 1:設置root帳號密碼 輸入命令: sudo passwd root 根據提示輸入root帳號密碼。 step 2:保證以root帳號權限進行後續操作 如果不是用root帳號登錄系統 輸入命令: su ro
Date.parseDate( String input, String format ) : Date 將字符串string依指定的格式format轉換爲時間,其中格式定義詳見format方法 例:dt = Date.parseDat
前端面試題 - 說一下原型和原型鏈? JavaScript 中,萬物皆對象,對象分爲普通對象和函數對象。 所有的函數都是函數對象(typeof f === 'function'),其他都是普通對象(typeof o === 'object'
唯一索引(Unique Index):保證索引列的值是唯一的,即重複值不允許。 非唯一索引(Non-Unique Index):允許重複值存在。 組合索引(Composite Index):在表的多個列上創建索引。 反向鍵索引(Rever
IPD(集成產品開發)模型的核心價值在於它改變了企業對於產品研發的固有觀點,將企業產研的重點由“技術爲導向”升級爲“用戶需求爲導向”,強調企業在產品的研發過程中堅持以用戶/客戶爲中心。 在IPD(集成產品開發)的模式中,需要企業或者團隊在限
用於衡量算法佔用內存空間隨着數據量變大時的增長趨勢。這個概念與時 間複雜度非常類似,只需將“運行時間”替換爲“佔用內存空間”。 算法在運行過程中使用的內存空間主要包括以下幾種。 ‧ 輸入空間:用於存儲算法的輸入數據。
/** * 處理富文本里的圖片寬度自適應 * 1.去掉img標籤裏的style、width、height屬性 * 2.img標籤添加style屬性:max-width:100%;height:auto * 3.修改所有style裏的
本文主要列舉了省市三級聯動的DropDownList+Ajax的三種框架(aspnet/Jquery/ExtJs)示例。前段時間需要作一個的Web前端應用,需要用多個框架,一個典型的應用場景是省市三級聯動,基於此應用,特將三種主要的aja
jQuery之ajax post篇------Code <script type="text/javascript">function adddata() { var typeName=$("#<%=this.typeNa