cf264 div2E题 E. Caisa and Tree(dfs转化为有根树暴力求解)

博客介绍了CF264 Div2 E题的解决方案,通过DFS转换图形成有根树,并进行暴力搜索。作者分享了首次解决E题的兴奋之情,并附上了相关代码。
摘要由CSDN通过智能技术生成

点击打开题目链接

题意很简单,直接暴力就可以做了。先dfs把图转化为有根树(记录父亲节点)然后暴力。下面直接贴代码(第一次做出E题,很激动有没有奋斗

#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5+10;
int pa[maxn],tree[maxn];
int n,q;
struct
{
    int to,next;
} e[2*maxn];
int head[maxn],tot,cnt;
bool vis[maxn];
int gcd(i
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值