题意:多组数据,最后的0/1表示0无向1有向。
问是否存在欧拉回路。
题解:无向边给它任意定个向。
首先欧拉回路中点入度=出度。
然后发现每个无向边如果修改个方向,原来的入点的入度+1,出度-1,出点反之。
然后我们不妨对入度和出度不同的点跟源汇中之一连边,容量为入出度差一半(每改一条边差-2)
然后原来的无向边联系图中各点,容量1,最后check if(maxflow...
分类:
其他好文 时间:
2015-01-07 09:21:54
阅读次数:
170
2666. Query on a tree IVProblem code: QTREE4You are given a tree (an acyclic undirected connected graph) with N nodes, and nodes numbered 1,2,3...,N. ...
分类:
其他好文 时间:
2015-01-07 00:31:02
阅读次数:
266
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled u...
分类:
其他好文 时间:
2015-01-05 07:03:18
阅读次数:
261
邻接矩阵的图示:构建一个这种无向邻接矩阵。參考站点:http://www.geeksforgeeks.org/graph-and-its-representations/这里写了个类,添加删除图的操作。#pragma once#include #include class AdjListGraph{...
分类:
编程语言 时间:
2015-01-03 17:09:04
阅读次数:
239
图的复制
class Solution {
public:
UndirectedGraphNode *cloneGraph(UndirectedGraphNode *node ){
unordered_mapmap;
if(node == NULL)
return NULL;
return clone(node,ma...
分类:
其他好文 时间:
2015-01-01 21:19:33
阅读次数:
289
Palindrome Partitioning IIGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a p...
分类:
其他好文 时间:
2015-01-01 16:00:58
阅读次数:
164
生成随机验证码package com.web;//验证码生成处理类import java.awt.BasicStroke;import java.awt.Color;import java.awt.Font;import java.awt.Graphics;import java.awt.Graph...
分类:
其他好文 时间:
2014-12-31 06:18:03
阅读次数:
210
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
其他好文 时间:
2014-12-30 16:38:28
阅读次数:
194
题解:如果我们直接由s向a1,b1连边,a2,b2向t连边之后求最大流判断是否满流是有问题的。因为有可能a1流到了b2,b1流到了a2.解决方法是交换b1和b2,再跑一遍,还满流才说明可行。脑补一下证明:不妨设第一次maxflow中a1->a2 an-xa1->b2 xb1->a2 bn-x b1-...
分类:
其他好文 时间:
2014-12-30 15:09:13
阅读次数:
132
题目:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled u...
分类:
其他好文 时间:
2014-12-30 07:03:08
阅读次数:
208