C. Searching for Graph(cf)】的更多相关文章

C. Searching for Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: the graph contains ex…
题目大意 我们说一个无向图是 p-interesting 当且仅当这个无向图满足如下条件: 1. 该图恰有 2 * n + p 条边 2. 该图没有自环和重边 3. 该图的任意一个包含 k 个节点的子图含有不超过 2 * k + p 条边 现在,请你找出一个 p-interesting 包含 n 个节点的无向图,输出他的 2 * n + p 条边 数据范围:5 ≤ n ≤ 24,0 ≤ p, 2 * n + p ≤ (n) * (n + 1) / 2 做法分析 好久没有做题了,刷刷水题练练手 第…
题目地址 /* 题意:要你构造一个有2n+p条边的图,使得,每一个含k个结点子图中,最多有2*k+p条边 水得可以啊,每个点向另外的点连通,只要不和自己连,不重边就可以,正好2*n+p就结束:) */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <map> #includ…
Just CS rookie practice on DFS\BFS. But details should be taken care of: 1. Ruby implementation got TLE so I switched to C++ 2. There's one space after each output node, including the last one. But SPOJ doesn't clarify it clearly. #include <iostream>…
题目链接:http://codeforces.com/problemset/problem/402/C /**算法分析: 乱搞题,不明白题目想考什么 */ #include<bits/stdc++.h> #define MAXN 1050 #define PI acos(-1.0) #define REP(i,n) for(int i=0; i<n; i++) #define FOR(i,s,t) for(int i=s; i<=t; i++) #define mem(a,b) m…
A. Nuts time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a…
Introduction to Algorithms 2nd ed. Cambridge, MA: MIT Press, 2001. ISBN: 9780262032933. Introduction and document distance L1 Introduction and document distance CLRS, chapters 1-3 L2 More document distance, mergesort CLRS, sections 11.1-11.2 Binary s…
CF1082A Vasya and Book 模拟一下即可 \(Code\ Below:\) #include <bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; int n,x,y,d,ans; int main() { int T; scanf("%d",&T); while(T--){ scanf("%d%d%d%d",&n,&x,&y,&am…
cf 542E - Playing on Graph 题目大意 给定一个\(n\le 1000\)个点的图 求经过一系列收缩操作后能否得到一条链,以及能得到的最长链是多长 收缩操作: 选择两个不直接相连的点,构造一个新点 对于原图中的每一个点,如果它与这两个点中的任意一个有连边 那么它向这个新点连一条边 最后删除选择的两个点,以及所有这两个点的连边 分析 注意到对于一个奇环,无论怎么收缩,都会产生一个新的奇环,最后奇环变成一个三角形,再也缩不了,永远无法变成一条链 只有偶环的图是二分图 对于图中…
C. Graph Reconstruction time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. Fo…