CF1093D Beautiful Graph】的更多相关文章

思路: 题目倒是没啥好说的,就是注意memset的效率问题.如果循环多次调用memset去初始化一个比较大的数组,那就会很费时间.就是因为这个被hack了.:( 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ; vector<int> G[MAXN]; int col[MAXN]; int n, m; ll c1 = , c2 = , bin[MAXN]; bool dfs(int…
题目链接:Beautiful Graph 题意:给定一张无向无权图,每个顶点可以赋值1,2,3,现要求相邻节点一奇一偶,求符合要求的图的个数. 题解:由于一奇一偶,需二分图判定,染色.判定失败,直接输出0.成功的话,统计下奇数(cnt1)和偶数(cnt2)顶点个数,只有奇数有两种,也就是说有$2^{cnt1}$种,但是可以把奇数和偶数顶点翻转,奇变偶,偶变奇,即最后有$2^{cnt1}+2^{cnt2}$种,注意此图可能不连通,各个图之间的答案数要相乘. #include <set> #inc…
传送门:http://codeforces.com/contest/1093/problem/D D. Beautiful Graph time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an undirected unweighted graph consisting of nn vertices a…
D - Beautiful Graph CodeForces - 1093D You are given an undirected unweighted graph consisting of nn vertices and mm edges. You have to write a number on each vertex of the graph. Each number should be 11, 22or 33. The graph becomes beautiful if for…
<题目链接> 题目大意: 给你一个无向图(该无向图无自环,且无重边),现在要你给这个无向图的点加权,所加权值可以是1,2,3.给这些点加权之后,要使得任意边的两个端点权值之和为奇数,问总共有多少种可能?结果mod 998244353. 解题分析: 整张图的所有顶点赋权之后,一定分为奇.偶两部分点集,并且,要想使的该图满足条件,任意边的两个端点的奇偶性应该是不同的,所以我们可以用DFS对图进行二分图染色,将图分为两个部分,需要注意的是,该图未必连通.然后就是DFS的过程中,如果下一个点已经染过色…
题意:给定无向图,让你给点加权(1,2,3),使得每条边是两端点点权和维奇数. 思路:一个连通块是个二分图,判定二分图可以dfs,并查集,2-sat染色. 这里用的并查集(还可以带权并查集优化一下,或者干脆用dfs). 计数的时候每个连通块单独考虑,我们从连通块的第一个点开始dfs,如果是该填奇数点,那么当前方案数*=2:分第一个点奇偶两种情况即可. (多组输入一定注意初始化,这次CF多组输入好坑啊... #include<bits/stdc++.h> #define ll long long…
题意: 给你一个图,每个节点可以赋值1,2,3三种数字,相邻的节点的和必须是奇数,问有多少中方法. 分析: 很容易就可以发现如果这个图中是有奇数的环的话,那这是肯定不行的 ,否则这个环的贡献是为2^sumji+2^sumou , 总贡献为每个的环的贡献相乘,一个点也为环: #include<bits/stdc++.h> using namespace std ; #define mod 998244353 #define ll long long ; vector<int>G[ma…
​题目大意: 在给定的一个图中(可能不连通) 给每个点赋值1.2.3 使得一条边上的两个端点点权相加为奇数 求方案数 一条满足条件的路径上的点权必为一奇一偶交替 偶数只有2 奇数有1.3 若位于1.3.5..... 的点有x1个 位于2.4.6.... 的点有x0个 那么一条路径的方案数为 2^x1+2^x0 (x1的点作为奇数点的方案+x0的点作为奇数点的方案) 当图不连通 存在多个子图 那么每个子图的方案数相乘 就是总的方案数 当图中存在环时 若环上的点数为偶数则同样满足上式 但为奇数则整条…
这个题深搜容易解决,结果用了广搜,动手之前还是要想清楚,然后自己的代码写错的情况下,没有重写,而是在原有的基础上,进行修改,结果有个判定的初始化条件放错位置,浪费了一个小时... 就是给一个无向图,任务时给点附上1,2,或者3,使得每条边相连的两个顶点数字之和位基数,求一共有多少种方案. 本来准备放自己的代码,算了,还是官方题解比较简洁,有那个for写的很短,而且我写的有好几个函数,检查起来跳来跳去的,以后短的代码还是尽量写在主函数吧 #include <bits/stdc++.h> usin…
题意:有\(n\)个点,\(m\)条边的无向图,可以给每个点赋点权\({1,2,3}\),使得每个点连的奇偶不同,问有多少种方案,答案对\(998244353\)取模. 题解:要使得每个点所连的奇偶不同,很明显是二分图染色,那么对于某一个联通块,我们可以对左边的点赋\(2\),右边的点赋\({1,3}\),那么左边的点没有选择,只有一种情况,而右边的点每个点可以有两种情况,如果右边的点数是\(k_2\),那么方案数就是\(2^{k_2}\),如果左边赋\({1,3}\)且点数为\(k_1\),右…
Description Vasya's dad is good in maths. Lately his favorite objects have been "beautiful" directed graphs. Dad calls a graph "beautiful" if all the following conditions are true: The graph contains exactly \(N\) vertices and \(N−1\)…
涨rating啦.. 不过话说为什么有这么多数据结构题啊,难道是中国人出的? A - Dice Rolling 傻逼题,可以用一个三加一堆二或者用一堆二,那就直接.. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<c…
A. Dice Rolling 签到. #include <bits/stdc++.h> using namespace std; int t, n; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); ) puts("); else { ; res += n / ; printf(); } } ; } B. Letters Rearranging 签到. #…
题目链接:https://codeforces.com/contest/1093 A. Dice Rolling 题意: 有一个号数为2-7的骰子,现在有一个人他想扔到几就能扔到几,现在问需要扔多少次,能使扔出的总和等于xi. 题解: 由于是special judge,模拟一下搞搞就行了= = 代码如下: #include <bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; int n; while(t--…
CF-1093 1093A - Dice Rolling 输出x/2即可 #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x; cin >> x; cout << x / 2 << endl; } return 0; } 1093B - Letters Rearranging 当且仅当字符串中所有字符都相同时,…
目录: 1.1093D. Beautiful Graph(DFS染色) 2.514C - Watto and Mechanism(Tire) 3.69E.Subsegments(STL) 4.25C. Roads in Berland(最短路松弛操作) 5.128B. String Problem (floyd预处理) 6.33C.Wonderful Randomized Sum(思维) 7.1292B.Aroma's Search (暴力+思维) 8.1286 A.Garland(DP) 9.…
A. Dice Rolling 把\(x\)分解为\(a * 6 + b\),其中\(a\)是满6数,\(b\)满足\(1 <= b < 6\),即可... #include <iostream> #include <cstdio> using namespace std; int main(){ int T; scanf("%d", &T); while(T--){ int x; scanf("%d", &x);…
reference:http://www.egrappler.com/javascript-chart-and-graph-libraries-for-developers/ BY TEAMEGRAPPLER · MARCH 4, 2014   Graphs and charts are used to simplify complex data and make it easy to read and understand. There is a growing number of Open…
Description In graph theory, a matching or independent edge set in a graph G = (V , E) is a set of edges ME such that no two edges in the matching M share a common vertex. The Nobel Prize in XiXiHaHa was awarded to Jerryxf team, amongst other things,…
TimeWall is a graph databases github It be used to apply mathematic model and social network with graph algorithms and so on... Features: 1. C/S structure 2. compute in memory 3. dynamic add and remove nodes on the graph db 4. with lots of algorithms…
这几篇博文只是为了记录学习Beautiful Soup的过程,不仅方便自己以后查看,也许能帮到同样在学习这个技术的朋友.通过学习Beautiful Soup基础知识 完成了一个简单的爬虫服务:从allitebooks.com抓取书籍的书名和每本书对应的ISBN码,然后通过ISBN码去amazon.com抓取对应的价格. 第一部分 Beautiful Soup的基础知识 Beautiful Soup的安装和查找.浏览的方法. 网络爬虫: 从allitebooks.com抓取书籍信息并从amazon…
开始学习网络数据挖掘方面的知识,首先从Beautiful Soup入手(Beautiful Soup是一个Python库,功能是从HTML和XML中解析数据),打算以三篇博文纪录学习Beautiful Soup的过程,第一篇是Beautiful Soup基础知识,后两篇利用前边的Beautiful Soup知识完成一个简单的爬虫,抓取allitebook.com的书籍信息和ISBN码,再根据ISBN码去amazon.com抓取书籍对应的价格. 一.Beautiful Soup简介 网络数据挖掘指…
Source: Connected Brain Figure above: Bullmore E, Sporns O. Complex brain networks: graph theoretical analysis of structural and functional systems.[J]. Nature Reviews Neuroscience, 2009, 10(3):186-198. Graph measures A graph G consisting of a set of…
Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2635   Special Judge Description Alice and Bob play the following game. First, Alice draws some directed graph with N vertices and M arcs. After that B…
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph. Example 1: 0          3 |          | 1 --- 2    4 Given n = 5 and…
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. For example: Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return tru…
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 uniquely. We use # as a separator for each node, and , as a separator for node label and each neigh…
Influence maximization on big social graph Fanju PPT链接: social influence booming of online social network 一, Application:viral marketing 1, identify influence customers: seeds. 2, convince them to adopter product. other application: Rumor monitoring…
关于zabbix的API见,zabbixAPI 1item批量添加 我是根据我这边的具体情况来做的,本来想在模板里面添加item,但是看了看API不支持,只是支持在host里面添加,所以我先在一个host里面添加,然后在将item全部移动到模板里. 具体步骤就不说了,直接上代码: 为了快速完成,代码写的有点乱,也没怎么处理异常,算是第一版吧,有时间在优化  1 #!/usr/bin/env python #-*- coding: utf- -*- import json import sys i…
Graph Structure Graph Definition theano's symbolic mathematical computation, which is composed of: Apply node: the application of an operator to some variable. Variable node: symbolic varibles. Op node: mathematical operation like: +,-,*,\,sqrt,sum,t…