Пример #1
0
Файл: h.cpp Проект: kzoacn/OI
	inline int isap(int s, int t) {
		int ans = 0, now = s;
		for (int i = 1; i <= n; i++)
			cur[i] = point[i];
		bfs(t);

		while (deep[s] < n) {
			if (now == t) {
				ans += add_flow(s, t);
				now = s;
			}
			bool isok = false;
			for (int tmp = cur[now], u; u = v[tmp], tmp != -1; tmp = nxt[tmp])
				if (remain[tmp] && deep[u] + 1 == deep[now]) {
					isok = true;
					last_edge[u] = tmp;
					cur[now] = tmp;
					now = u;
					break;
				}
			if (!isok) {
				int minn = n - 1;
				for (int tmp = point[now], u; u = v[tmp], tmp != -1; tmp = nxt[tmp])
					if (remain[tmp])
						minn = min(minn, deep[u]);
				if (!(--num[deep[now]])) break;
				num[deep[now] = minn + 1]++;
				cur[now] = point[now];
				if (now != s)
					now = v[last_edge[now] ^ 1];
			}
		}
		return ans;
	}
Пример #2
0
static void add_flow_word(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style, const char *a, const char *b)
{
    fz_html_flow *flow = add_flow(ctx, pool, top, style, FLOW_WORD);
    flow->content.text = fz_pool_alloc(ctx, pool, b - a + 1);
    memcpy(flow->content.text, a, b - a);
    flow->content.text[b - a] = 0;
}
Пример #3
0
static void add_flow_image(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style, fz_image *img)
{
    fz_html_flow *flow;
    add_flow_glue(ctx, pool, top, style, "", 0);
    flow = add_flow(ctx, pool, top, style, FLOW_IMAGE);
    flow->content.image = fz_keep_image(ctx, img);
    add_flow_glue(ctx, pool, top, style, "", 0);
}
Пример #4
0
static void add_flow_space(fz_context *ctx, fz_html *top, fz_css_style *style)
{
	fz_html_flow *flow;

	/* delete space at the beginning of the line */
	if (!top->flow_head)
		return;

	flow = add_flow(ctx, top, style, FLOW_GLUE);
	flow->text = " ";
	flow->broken_text = "";
}
Пример #5
0
 int maxFlow(){
     int cost = 0,flow = 0;
     SPFA();
     while(true){
         while(true){
             for(int i = 0;i<node;i++) use[i] = 0;
             if(!add_flow(s, INF,flow,cost)) break;
         }
         if(!modify_label()) break;
     }
     return cost;
 }
Пример #6
0
 int add_flow(int u,int flow,int &maxFlow,int &minCost){
     if(u == t){
         maxFlow+=flow;
         minCost+=dis[s]*flow;
         return flow;
     }
     use[u] = true;
     int now = flow;
     for(int i = head[u];~i;i = nxt[i]){
         int &v = e[i].to;
         if(e[i].cap>e[i].flow&&!use[v]&&dis[u]==dis[v]+e[i].cost){
             int tmp = add_flow(v, min(now,e[i].cap-e[i].flow),maxFlow,minCost);
             e[i].flow+=tmp;
             e[i^1].flow-=tmp;
             now-=tmp;
             if(!now) break;
         }
     }
     return flow-now;
 }
Пример #7
0
int main() {
    int oxm_ofb_match_fields[40];
    int ofp_action_type[28];
    int capacity;
    int idx = 0;
    if (hw_properties(oxm_ofb_match_fields, ofp_action_type, &capacity) == 0) {
        printf("init suc\n");
    }

    add_flow(mac[0],mac[1],0x0800,1,3,idx++);
    add_flow(mac[1],mac[0],0x0800,3,1,idx++);
    add_flow(mac[2],mac[0],0x0806,3,1,idx++);
    add_flow(mac[2],mac[1],0x0806,1,3,idx++);
    add_flow(mac[0],mac[1],0x0806,1,3,idx++);
    add_flow(mac[1],mac[0],0x0806,3,1,idx++);
    return 0;
}
Пример #8
0
static void add_flow_break(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style)
{
    fz_html_flow *flow = add_flow(ctx, pool, top, style, FLOW_BREAK);
    flow->content.text = "";
}
Пример #9
0
static void add_flow_glue(fz_context *ctx, fz_pool *pool, fz_html *top, fz_css_style *style, const char *text, int expand)
{
    fz_html_flow *flow = add_flow(ctx, pool, top, style, FLOW_GLUE);
    flow->content.text = (char*)text;
    flow->expand = !!expand;
}
Пример #10
0
static void add_flow_image(fz_context *ctx, fz_html *top, fz_css_style *style, fz_image *img)
{
	fz_html_flow *flow = add_flow(ctx, top, style, FLOW_IMAGE);
	flow->image = fz_keep_image(ctx, img);
}