Title Link: http://www.spoj.pl/problems/HIGH/
Test instructions: The minimum number of spanning trees is obtained.
1#include <algorithm>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <iostream>6 #definell Long Long7 Doublea[205][205];8 intn,m;9 Const Doubleeps=1e- the;Ten intZeroDoublex) { One if(x<-eps)return-1; A Else returnX>EPS; - } - DoubleWork () { the Doubleres=1; - for(intI=1; i<=n;i++){ - intk=i; - for(intj=i+1; j<=n;j++)if(Fabs (A[j][i]) >fabs (A[k][i]) k=J; + if(k!=i) { - for(intj=1; j<=n;j++) + Std::swap (A[k][j],a[i][j]); A } at for(intj=i+1; j<=n;j++){ - Doubletmp=a[j][i]/A[i][i]; - for(intk=i;k<=n;k++) -a[j][k]-=tmp*A[i][k]; - } - if(!zero (A[i][i]))return 0; in } - for(intI=1; i<=n;i++) res*=A[i][i]; to returnStd::fabs (res); + } - intMain () { the intT; *scanf"%d",&T); $ while(t--){Panax Notoginsengscanf"%d%d",&n,&m); - for(intI=0; i<=n;i++) the for(intj=0; j<=n;j++) +a[i][j]=0; A while(m--){ the intx, y; +scanf"%d%d",&x,&y); -a[x][x]+=1.0; a[y][y]+=1.0; $a[x][y]-=1.0; a[y][x]-=1.0; $ } -n--; -printf"%0.0lf\n", work ()); the } -}
SPOJ 106 Highways (minimum spanning tree count)