Codeforces #48G: Galaxy Union 题解

这是一篇关于Codeforces第48场比赛中Galaxy Union问题的题解。博客首先介绍了问题背景,这是一个具有n个点和n条边的连通图,被构造成一个基环外向树。作者建议使用深度优先搜索来查找环,然后通过树形动态规划解决每个点到达树内部节点的问题,最后采用双指针技术处理到达其他树和环上节点的答案。博客重点在于提高代码实现能力。
摘要由CSDN通过智能技术生成

n个点n条边的连通图,是一个基环外向树

先用一遍深搜把环找出来

然后对于每一个点的答案,他到树内部的答案可以树型dp搞一搞,到其他树以及到环上的点的答案可以在环上two pointers搞一搞

主要是一道代码能力题

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值