Codeforces 362D Fools and Foolproof Roads】的更多相关文章

Fools and Foolproof Roads 并查集瞎搞搞就行, 有点小坑点. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int> #define S…
题目链接:点击打开链接 题意: 给定n个点 m条边的无向图 须要在图里添加p条边 使得图最后连通分量数为q 问是否可行,不可行输出NO 可行输出YES,并输出加入的p条边. set走起.. #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<vector> #include<set> using namespace s…
D. Fools and Foolproof Roads   You must have heard all about the Foolland on your Geography lessons. Specifically, you must know that federal structure of this country has been the same for many centuries. The country consists of n cities, some pairs…
题目链接:Codeforces 191C Fools and Roads 题目大意:给定一个N节点的数.然后有M次操作,每次从u移动到v.问说每条边被移动过的次数. 解题思路:树链剖分维护边,用一个数组标记就可以,不须要用线段树. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1e5 + 5; int N, Q, ne, fi…
Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得得到的子图联通并且总代价最小,输出最小总代价和一种方案. 虽然题目里描述的很冗长,但其实这个图有一些性质:它最初是一条链/一个环,然后再有一些结点直接连到这些在链上/环上的结点.. 下图就是一个(就是样例): 做法 首先我们可以简单的查看点的度数来找到链/环上的点,和连接它们的边. 然后我们可以通过…
C - Important RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88926#problem/C Description The city where Georgie lives has n junctions some of which are connected by bidirectional roads. Every d…
Description Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer. Once a year t…
D. Directed Roads time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered…
题目链接:D Directed Roads 题意:给出n个点和n条边,n条边一定都是从1~n点出发的有向边.这个图被认为是有环的,现在问你有多少个边的set,满足对这个set里的所有边恰好反转一次(方向反转),使得这个图里没有环. 思路:感觉关键是,n个点n条边,且每个点的出度为1,所以图里一定没有复环.想要使图里没环,对于每个连通块(点数为i)里的环(如果有环 点数为j),只要不是全翻和全不翻都是满足题意的set, 一共满足题意得set  即为 2^(i-j) * (2^j-2).所有的连通块…
F. Roads in the Kingdom time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the Kingdom K., there are n towns numbered with integers from 1 to n. The towns are connected by n bi-directional…