CodeForces - 977E】的更多相关文章

Cyclic Components CodeForces - 977E You are given an undirected graph consisting of nn vertices and mm edges. Your task is to find the number of connected components which are cycles. Here are some definitions of graph theory. An undirected graph con…
题:https://codeforces.com/problemset/problem/977/E 题意:给你一个图,问你有几个没有杂边的单环(度全为2) 分析:单环点的度数一定是2,连续边,判断是否连通,如果连通,ans++,否则连接这个边 #include<bits/stdc++.h> using namespace std; ; int f[M],a[M],b[M],du[M]; int findd(int x){ return x==f[x]?x:f[x]=findd(f[x]); }…
题意 给出nnn个顶点和mmm条边,求这个图中环的个数 思路 利用并查集的性质,环上的顶点都在同一个集合中 在输入的时候记录下来每个顶点的度数,查找两个点相连,且度数均为222的点,如果这两个点的父节点相同,表示这两个点在一个环中,环的个数+1+1+1 AC代码 /************************************************************************* > File Name: E.cpp > Author: WZY > QQ:…
题意: 就是找出所有环的个数, 但这个环中的每个点都必须只在一个环中 解析: 在找环的过程中 判断度数是否为2就行...emm... #include <bits/stdc++.h> using namespace std; , INF = 0x7fffffff; int n, m, s, t, flag; vector<int> G[maxn]; int vis[maxn], res; void dfs(int u, int fa) { vis[u] = ; ; i<G[u…
A. Wrong Subtraction 题目大意:   定义一种运算,让你去模拟 题解:   模拟 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <stack> #includ…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…