Codeforces Round #338 (Div. 2) B. Longtail Hedgehog

LTspice仿真实战:共模电感差模/共模插入损耗测试全流程(附WE 744821201参数) 本文以Würth Elektronik 744821201型号共模电感为例,详细介绍了在LTspice中搭建差模与共模插入损耗测试电路的全流程。通过从规格书提取关键参数、构建SPICE模型,到执行仿真并与官方数据对比,旨在帮助硬件工程师在PCB设计前期精准预测EMC性能,弥合器件选型与系统设计之间的鸿沟。 阅读详情

B. Longtail Hedgehog
time limit per test3 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn’t matter). No two segments connect the same pair of points, and no segment connects the point to itself. Masha wants to color some segments in order paint a hedgehog. In Mashas mind every hedgehog consists of a tail and some spines. She wants to paint the tail that satisfies the following conditions:

Only segments already presented on the picture can be painted;
The tail should be continuous, i.e. consists of some sequence of points, such that every two neighbouring points are connected by a colored segment;
The numbers of points from the beginning of the tail to the end should strictly increase.
Masha defines the length of the tail as the number of points in it. Also, she wants to paint some spines. To do so, Masha will paint all the segments, such that one of their ends is the endpoint of the tail. Masha defines the beauty of a hedgehog as the length of the tail multiplied by the number of spines. Masha wants to color the most beautiful hedgehog. Help her calculate what result she may hope to get.

Note that according to Masha’s definition of a hedgehog, one segment may simultaneously serve as a spine and a part of the tail (she is a little girl after all). Take a look at the picture for further clarifications.

Input
First line of the input contains two integers n and m(2 ≤ n ≤ 100 000, 1 ≤ m ≤ 200 000) — the number of points and the number segments on the picture respectively.

Then follow m lines, each containing two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the numbers of points connected by corresponding segment. It’s guaranteed that no two segments connect the same pair of points.

Output
Print the maximum possible value of the hedgehog’s beauty.

Sample test(s)
input
8 6
4 5
3 5
2 5
1 2
2 8
6 7
output
9
input
4 6
1 2
1 3
1 4
2 3
2 4
3 4
output
12
Note
The picture below corresponds to the first sample. Segments that form the hedgehog are painted red. The tail consists of a sequence of points with numbers 1, 2 and 5. The following segments are spines: (2, 5), (3, 5) and (4, 5). Therefore, the beauty of the hedgehog is equal to 3·3 = 9.

题目链接:http://codeforces.com/problemset/problem/615/B
题目大意:
寒假里,做功课之余,小明也非常喜欢画画。某一天,爸爸给他了一幅画和一只铅笔。这幅画包含了n个点和m条线(这些边可能会相交,但是我们不用去管这些)。每条线的两端是两个不同的点,没有任何两条线的两个端点是完全一样的。现在,小明想要给一些线条涂颜色,目的是画出一只刺猬来。在小明的印象中,刺猬应该有一个尾巴和几根刺。他觉得画尾巴的时候应该满足如下规律:
1、只有已经存在的线条才可以被涂上颜色。
2、尾巴应该是连续的,包含了一系列的点,每两个点之间的线条被涂上了颜色。
3、尾巴上的顶点的序号应该要严格递增。

小明觉得尾巴的长度就是尾巴上点的个数。同时,他也要去画刺猬的刺,因此他把一些线条也涂上了颜色,刺的一个端点必须在尾巴的末端点上。小明觉得刺猬的美观值应该是尾巴的长度乘以刺的数量。小明希望画出一只美观值最大的刺猬。虽然大家觉得小明的想法很幼稚,但是他毕竟还是一个小盆友。。。

Input
输入第一行包含两个正整数n和m,分别表示点和线的数量。(2<=n<=100000,1<=m<=200000)。
接下来m行,每行两个正整数ui和vi,表示第i条线两端的点的序号,1<= ui,vi<= n。数据保证没有两条线的两个端点完全一样。

Output

输出最大的美观值

解题思路:把每个点当作尾巴的末端点,所以连接这个点的点个数就是刺的个数,比这个点小的数的个数加上它本身就是尾巴长度。枚举每个点作为尾巴的末端点,记录得到的最大美观值,注意尾巴长度初始化为1,用long long。

代码如下:

#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define ll long long 
using namespace std;
const int maxn=100000+10;
vector <int >vt[maxn];
ll dp[maxn];
ll num[maxn];
int main(void)
{
    int n,m,u,v;
    memset(num,0,sizeof(num));
    for(int i=0;i<maxn;i++)
        dp[i]=1;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&u,&v);
        vt[v].push_back(u);
        vt[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
    {
        num[i]=(ll)vt[i].size();
    }
    ll ans=0;
    dp[1]=1;
    for(int i=1;i<=n;i++)
    {
        int len=vt[i].size();
        for(int j=0;j<len;j++)
        {
            int cur=vt[i][j];
            if(cur>i)
                dp[cur]=max(dp[cur],dp[i]+1);
        }
    }
    for(int i=1;i<=n;i++)
    {
        ll cur=dp[i]*num[i];
        ans=max(cur,ans);
    }
    printf("%lld\n",ans );
}
JY02无刷电机驱动芯片的硬件设计与调试实战 本文详细介绍了JY02无刷电机驱动芯片的硬件设计与调试实战。重点解析了其外置MOSFET的设计优势,提供了从电源滤波、功率MOSFET选型到电流采样保护的核心电路设计指南。文章还分享了安全上电、动态测试及常见问题排查的完整调试流程,并探讨了开关优化、闭环测速等性能提升技巧,帮助开发者构建稳定高效的无刷电机驱动系统。 阅读详情

相关推荐

Visual Tracker Benchamark傻瓜式教程(二)

问题  1 1  在调用main.m跑TRE和SRE时,因为会生成相应的.mat数据文件,如果跑完以后发现自己算法生成的.mat文件有问题,那么要把该文件删除,待找到错误原因后,重新生成相应的.mat文件。因为程序中写的是如果已经存在了.mat文件,例如已经存在car4_STC.mat文件,即使该文件中的数据有错误,但是重新跑时会默认该文件中的数据写完,不会重新写入数据 问题  2  b

mingbujingren的专栏 9929

B. Longtail Hedgehog(DP+简单图论)

B. Longtail Hedgehog This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn’t matter). No two s...

qq_43627100的博客 1105

SMIC Memory配置与Library Compiler实战:从lib到db的高效转换

本文详细介绍了SMIC Memory Compiler的配置要点与使用Library Compiler将.lib文件高效转换为.db文件的完整流程。文章深入解析了关键配置参数对性能和面积的影响,并提供了从交互式操作到自动化脚本的实战指南,帮助数字芯片设计工程师顺利完成存储器模型的生成与集成,确保Design Compiler能正确调用。

weixin_28314575的博客 338

Codeforces 615B Longtail Hedgehog 【dp】

B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magi

世界很大 1036

C#对接EtherNet/IP协议 完整版|罗克韦尔AB PLC通信+CIP核心概念全解析

你做罗克韦尔(AB) PLC工业上位机开发,是唯一的首选协议,没有之一!EtherNet/IP(Ethernet Industrial Protocol)是基于标准以太网的工业级通信协议,由罗克韦尔自动化主导开发,是ODVA(开放设备网络供应商协会)主推的工业以太网标准,也是目前全球应用最广泛的工业以太网协议之一。原生适配罗克韦尔AB PLC:Micro800、CompactLogix、ControlLogix、Micro850等全系AB PLC原生标配EtherNet/IP,无需额外配置,开箱即用;

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 909

企业级大数据平台的数据网格(Data Mesh)转型之路

随着企业数字化转型的深入,传统大数据平台面临数据孤岛化、治理成本高、业务响应慢等核心痛点。数据网格作为一种新兴的分布式数据管理架构,通过领域驱动设计(DDD)、数据产品化和联邦治理模式,为企业提供了打破数据壁垒、提升数据生产力的全新路径。本文聚焦企业级数据平台从传统架构(数据湖/数据仓库)向数据网格转型的关键技术、实施步骤和组织配套,涵盖技术架构设计、核心算法实现、项目实战案例及工具链推荐。背景介绍:定义转型目标、术语体系与核心挑战核心概念与联系:解析数据网格四大支柱及技术架构图谱核心算法原理。

AI 领航者的博客 1085

Codeforces 615B - Longtail Hedgehog(DP)

B. Longtail Hedgehog time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output This Christmas Santa gave Masha a magic picture and a pencil. The pic

Snakeflute的博客 457

BP神经网络回归预测+SHAP可解释分析+新数据预测(MATLAB完整源码)

BP神经网络回归预测+SHAP可解释分析+新数据预测(MATLAB完整源码)

机器学习之心的博客,关注并私信文章链接,获取对应文章源码和数据。 399

Codeforces Round #338 (Div. 2)B. Longtail Hedgehog(贪心+dp)

B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magic picture

梧桐下的四叶草 537

2025年7月5日全国青少年信息素养大赛Python编程初中组复赛真题+答案解析

2025年7月5日全国青少年信息素养大赛Python编程初中组复赛真题+答案解析

伶俐角少儿编程 471

SAP 创建PO时提示“不能确定任何组件”

SAP 创建委外加工的PO时提示“不能确定任何组件” 而如果BOM已经创建了,但还是提示该错误保存。 解决办法:1. BOM selection 未配置好; 2. 由于Purchasing prosessing time的设置,如果PO中的delivery time - Purchasing prosessing time是过去的日期,那么会找不到BOM,BOM的有效期需早 于PO审批的有效期。 3. BOM未...

willieyuan的博客 6126

CodeForces 615B Longtail Hedgehog(长尾巴的刺猬) 动态规划

B. Longtail Hedgehog time limit per test  3 seconds memory limit per test  256 megabytes input  standard input output  standard output This Christmas Santa gave Masha a

sxtopc的博客 3万+

uniapp APP端:蓝牙报错writeBLECharacteristicValue:fail property not support(uni.writeBLECharacteristicVal)

uni-app 蓝牙fail property not support、发现不了服务特征值的问题、突然发现微信蓝牙小秘密,使用uni-app编译成安卓APP后报错writeBLECharacteristicValue:fail property not support,发现不了服务特征值,uniApp APP调用蓝牙API发送指令过快导致,uniapp 蓝牙 writeBLECharacteristicValue property_not_support iOS Android BLE GATT 特征值写入

✅ 精选推荐文章 2949

Codeforces Round #338 (Div. 2) B. Longtail Hedgehog

要求:  求最长的尾巴数 和 身上的刺的数的乘积最大;           解决办法: 首先求出每个顶点的最大刺数  这个应该蛮好求的, 直接将每个点比它大的入度求出来就可以了;                               然后球每个顶点的最长尾巴数, 思路是排序加二分求;  先求出到第一个数的最长的序列, 然后依次求第二个数, 第三个数;方法是排序加二分; 我的代码

just_for_your_smile的专栏 2万+

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces Round #338 (Div. 2) B. Longtail Hedgehog DP

B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magi

qq1319479809的博客 478

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Codeforces Round #338 (Div. 2)B. Longtail Hedgehog解题报告

B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magic picture and a pencil.

Dafang_Xu的博客 1894

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Codeforces Round #338 (Div. 2) 615B Longtail Hedgehog(dp)

B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magi

GKHack's Blog 992

Codeforces Round #338 (Div. 2)B. Longtail Hedgehog(DP)

题意:有n个点,连接点画出刺猬的尾巴和刺,尾巴是由多个严格递增的点组成的线段,从该尾巴上选取一点,该点所连接的其余线段视为刺猬的刺,现在给出m条线段,每条线段连接两个不同的点,求出尾巴长度x刺的长度的最大值。即求某点的长度x深度的最大值。 dp[i]表示到i点最长的长度值len,记录i点的深度d,所求即为max(len x d); 扫描与i相连的且小于i的所有点即可; 状态转移方程即

To be excellent! 528

Codeforces Round #338 (Div. 2) B. Longtail Hedgehog dp

B. Longtail Hedgehog 题目连接: http://www.codeforces.com/contest/615/problem/B Description This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m seg...

weixin_34268843的博客 248

Codeforces Round #338 (Div. 2) B. Longtail Hedgehog(LIS)

题意: 给定N≤105,M≤2×105的无向图,求图上节点标号LIS给定N\le 10^5, M \le 2×10^5的无向图, 求图上节点标号LIS 输出答案maxni=1{LISi∗degi}输出答案max_{i=1}^n\{LIS_i*deg_i\} 分析: f[i]:=以节点i结尾的LIS长度,直接转移即可,总复杂度O(m)f[i]:=以节点i结尾的LIS长度, 直接转移即可,

TaoSama's Microcosm 346

Codeforces 615B Longtail Hedgehog (Round #338 (Div. 2) B题)

题意 给你一个无向图,让你找到一个通路,路上的点是依次增大的,点的个数记为len 然后找到所有连接到这条路末尾节点的边,数量为num 找到最大的num * len 思路 基本是枚举以第i个节点为结尾得到的num * len num很好得到,开个数组记录下就好 len的话,用了个小dp,dp(j) = max(dp(i) + 1 , dp(j)) 存在(i,j)这条边 存图直接只记录从小编号点到大编

luke2834的专栏 457

Codeforces Round #338 (Div. 2) B. Longtail Hedgehog 记忆化搜索/树DP

B. Longtail Hedgehog This Christmas Santa gave Masha a magic picture and a pencil. The picture consists ofnpoints connected bymsegments (they might cross in any way, that doesn't mat...

weixin_30527143的博客 184

Codeforces Round #338 (Div.2)

                                A. Bulbs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya wants to turn on Chri...

weixin_33672109的博客 161

Codeforces Round #338 (Div. 2) 解题报告

所以苟蒻万年不做E。。。 A: A. Bulbs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya wants to turn on Ch

CRZbulabula的博客 6086

Codeforces Round #338 (Div. 2)

水A- Bulbs #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; bool vis[110]; int main(void) { memset (vis, f...

weixin_33700350的博客 118

Codeforces Round #338 (Div. 2) ABCDE

A Bulbs随便模拟下。#include <bits/stdc++.h>using namespace std;#define ll long longbool vis [111];int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ int x; cin>>x; whi

A Cube Master 458
上一篇: noj 1073 成绩排名
下一篇: Codeforces Round #338 (Div. 2) C. Running Track
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值