题目链接 n个点, m条边, 问最少加几条边可以出现一个奇环, 在这种情况下, 有多少种加边的方式. 具体看代码解释 #include<bits/stdc++.h> using namespace std; #define pb(x) push_back(x) #define ll long long #define mk(x, y) make_pair(x, y) #define lson l, m, rt<<1 #define mem(a) memset(a, 0, sizeo…
Vitaly and Cycle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles…
题意简述 给定一个图 求至少添加多少条边使得它存在奇环 并求出添加的方案数 (注意不考虑自环) ----------------------------------------------------------------------------- 一道二分图染色的讨论题 比赛时只会用二分图染色判断树以及偶环 忘记用这个来判奇环... 二分图染色这种联赛知识点的题目现在也不会写了... ------------------------------------------------------…
http://www.cnblogs.com/wenruo/p/4959509.html 给一个图(不一定是连通图,无重边和自环),求练成一个长度为奇数的环最小需要加几条边,和加最少边的方案数. 很容易知道连的边数只能是0,1,2,3. 如果是二分图一定不含长度为奇数的环. 难点是如果是二分图怎么求方案数呢? 二分图染色时能求出每一个联通块.在每一个联通块中把任意两个颜色相同的点连一条边即可达到要求. 如图中红色和绿色的边就是部分可行解 代码(含注释): /*******************…
D. Vitaly and Cycle       time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked th…
D. Vitaly and Cycle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/problem/D Description After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an…
D. Vitaly and Cycle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycl…
题目链接: 点这里 题目 D. Vitaly and Cycle time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output 问题描述 After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an odd length in w…
题目链接: http://codeforces.com/problemset/problem/173/B 题意: 给你一个n*m的地图,现在有一束激光从左上角往左边射出,每遇到‘#’,你可以选择光线往四个方向射出,或者什么都不做,问最少需要多少个‘#’往四个方向射出才能使关系在n行往右边射出. 题解: 以行和列建二分图,如果str[i][j]=='#',则从i节点到j节点建一条双向边,权值都为1.然后对二分图跑一遍最短路. 代码: #include<iostream> #include<…