页面载入中
新的blog地址 http://www.gccfeli.cn

最新的blog地址

http://www.gccfeli.cn

http://www.gccfeli.cn

http://www.gccfeli.cn

http://www.gccfeli.cn

http://www.gccfeli.cn

http://www.gccfeli.cn

Felicia 发表于 2007-8-15 21:26:00
阅读全文 | 回复 | 引用通告
二分图匹配(类实现)

#i nclude<iostream>

using namespace std;

const int maxnx = 100, maxny = 100;

class match_c
{
public:
 void init(int _nx, int _ny);
 void add_edge(int u, int v);
 int make_match();

private:
 int nx, ny;
 int mlink[maxny];
 int mat[maxnx][maxny], done[maxny];
 int find(int k);
};

void match_c::init(int _nx, int _ny)
{
 nx = _nx;
 ny = _ny;
 memset(mat, 0, sizeof(mat));
}

inline void match_c::add_edge(int u, int v)
{
 mat[u][v] = 1;
}

int match_c::find(int k)
{
    int i, tmp;
    for (i = 0; i < ny; i++)
        if (!done[i] && mat[k][i] && mlink[i] == -1)
        {
            mlink[i] = k;
            done[i] = 1;
        &nbs
……

Felicia 发表于 2007-8-11 13:51:00
阅读全文 | 回复 | 引用通告
二分图最大权匹配(KM)

// ** Start of PerfectMatch *******************************
// Name: PerfectMatch by Kuhn_Munkras O(n^3)
// Description: w is the adjacency matrix, nx,ny are the size of x and y,
// lx, ly are the lables of x and y, fx[i], fy[i] is used for marking
// whether the i-th node is visited, matx[x] means x match matx[x],
// maty[y] means y match maty[y], actually, matx[x] is useless,
// all the arrays are start at 1

#i nclude <iostream>

using namespace std;

const int MAXN = 110;
const int INF = 0x7FFFFFFF;

int nx, ny, w[MAXN][MAXN], lx[MAXN], ly[MAXN];
int fx[MAXN], fy[MAXN], matx[MAXN], maty[MAXN];

int path(int u)
{
 fx[u] = 1;
 for (int v = 1; v <= ny; v++) if (lx[u] + ly[v] == w[u][v] && fy[v] < 0)
 {
  fy[v] = 1;
  if (maty[v] < 0 || path(maty[v]))
  {
   matx[u] = v;
   maty[v] = u;
   return 1;
  }
 }
 return 0;
}


……
Felicia 发表于 2007-8-6 17:01:00
阅读全文 | 回复 | 引用通告
表达式求值(递归下降法)
//支持 + - * / ( ) 表达式可含空格
#i nclude <iostream>
#i nclude <string>

using namespace std;

inline int is_op(char ch) {
 return ch=='+' || ch=='-' || ch=='*' || ch=='/';
}

string del_blank(string s) {
 string ret="";
 int i,len=s.size();
 for (i=0;i<len;i++) if (s[i]!=' ') ret.push_back(s[i]);
 return ret;
}

string del(string s) {
 int i,cnt=0,len=s.size();
 if (s[0]=='(' && s[len-1]==')') {
  string t=s;
  int flag=1;
  t[0]='.';
  t[len-1]='.';
  for (i=0;i<len;i++) {
   if (t[i]=='(') cnt++;
   if (t[i]==')') cnt--;
   if (cnt<0) {
    flag=0;
    break;
   }
  }
  if (flag) {
   t="";
   for (i=1;i<len-1;i++) t.push_back(s[i]);
   return del(t);
  }
  else re
……

Felicia 发表于 2007-7-21 9:27:00
阅读全文 | 回复 | 引用通告
[zz]平面点的曼哈顿最小生成树

平面点的曼哈顿最小生成树

引言


……
Felicia 发表于 2007-7-9 20:27:00
阅读全文 | 回复 | 引用通告
首页 上一页 下一页 尾页 页次:1/12页  5篇日志/页 转到:
公告
页面载入中
日历

<<  < 2008 - >  >>
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31


登陆
页面载入中
日志
页面载入中
回复
页面载入中
留言
页面载入中

信息
页面载入中
搜索

友情链接
Powered by Oblog.