codeforces C. Lorenzo Von Matterhorn

2026 具身智能 VLA/WAM 全栈学习与训练路线:从动作建模、SFT、RL 到世界模型的 RTX PRO 6000 96GB 单卡实战指南 我会把这张表做成“”而不是只列论文名:先核对每个模型截至的公开代码、训练目标和数据接口,再单独给你一套。对于没有公开、只有推理代码或训练细节不完整的模型,我会明确标出来,避免把“论文里提到”误写成“可复现”。目前有一个重要更新:。截至今天 NVIDIA 官方开源主线已经是换成 Cosmos-Reason2-2B/Qwen3-VL 架构,动作端仍是连续路线,而且官方明确给出单卡微调时默认只训练,峰值显存约。所以你的 96GB 单卡对 GR00T SFT 非常宽裕。可以。下面我按,把它整理成一张真正面向“ 阅读详情

C. Lorenzo Von Matterhorn
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two intersections.

Initially anyone can pass any road for free. But since SlapsGiving is ahead of us, there will q consecutive events happen soon. There are two types of events:

1. Government makes a new rule. A rule can be denoted by integers v, u and w. As the result of this action, the passing fee of all roads on the shortest path from u to v increases by w dollars.

2. Barney starts moving from some intersection v and goes to intersection u where there's a girl he wants to cuddle (using his fake name Lorenzo Von Matterhorn). He always uses the shortest path (visiting minimum number of intersections or roads) between two intersections.

Government needs your calculations. For each time Barney goes to cuddle a girl, you need to tell the government how much money he should pay (sum of passing fee of all roads he passes).

Input

The first line of input contains a single integer q (1 ≤ q ≤ 1 000).

The next q lines contain the information about the events in chronological order. Each event is described in form 1 v u w if it's an event when government makes a new rule about increasing the passing fee of all roads on the shortest path from u to v by w dollars, or in form 2 v u if it's an event when Barnie goes to cuddle from the intersection v to the intersection u.

1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109 states for every description line.

Output

For each event of second type print the sum of passing fee of all roads Barney passes in this event, in one line. Print the answers in chronological order of corresponding events.

Example
input
7
1 3 4 30
1 4 1 2
1 3 6 8
2 4 3
1 6 1 40
2 3 7
2 2 4
output
94
0
32
Note

In the example testcase:

Here are the intersections used:

  1. Intersections on the path are 3, 1, 2 and 4.
  2. Intersections on the path are 4, 2 and 1.
  3. Intersections on the path are only 3 and 6.
  4. Intersections on the path are 4, 2, 1 and 3. Passing fee of roads on the path are 32, 32 and 30 in order. So answer equals to32 + 32 + 30 = 94.
  5. Intersections on the path are 6, 3 and 1.
  6. Intersections on the path are 3 and 7. Passing fee of the road between them is 0.
  7. Intersections on the path are 2 and 4. Passing fee of the road between them is 32 (increased by 30 in the first event and by 2 in the second).

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
typedef long long ll;

using namespace std;

void swap(ll &x, ll &y) {
    ll t = x;
    x = y;
    y = t;
}

int main()
{
    int q, c;
    map<ll, ll> m;
    ll v, u, w;
    m.clear();
    cin >> q;
    while (q--) {
        scanf("%d", &c);
        scanf("%I64d%I64d", &v, &u);
        if (c == 1) {
            scanf("%I64d", &w);
            while (v != u) {
                //时刻保持从子节点往父节点的方向算
                if (v < u) {
                    swap(v, u);
                }
                m[v] += w;
                v /= 2;
            }
        } else {
            ll ans = 0;
            while (v != u) {
                if (v < u) {
                    swap(v, u);
                }
                ans += m[v];
                v /= 2;
            }
            printf("%I64d\n", ans);
        }
    }
    return 0;
}







WRF-CHEM 新手向实践(四):化学初始/边界场及namelist设置 这是这个系列的最后一节了,这些经验是自己作为一个半路出家的外行一步步摸索出来的,其中不免有很多理解不到位的地方,但也正是如此,我相信这是目前新手入门wrf-chem最友好的教程之一,希望能对大家有实质性的帮助。本节继续未完成的内容。在mozbc生成化学初始和边界条件之前,还需要先在wrfinput文件中开启化学部分。 阅读详情

相关推荐

魔改xjar支持springboot3,

其实这里基本就没问题了,实际项目中只要把这个spring-core包从私仓中替换,项目加密也就没有太大的毛病,但是这样对于追求完美的我来说,方便性还差点。原因找到了,看了下springboot github的issue,官方确实变更了,原因是因为springboot2中的。xjar项目文档还是不错的,clone下来,跟着文档,很容易就测试并通过了我的测试项目,于是便推给其他同事使用了。方法,那么问题来了,为啥springboot2没问题,spring3读取出来的却又是加密的,这是为毛?

jioulongzi的专栏 1550

Codeforces - Binary Tree on Plane

题目链接:Codeforces - Binary Tree on Plane 什么是二叉树呢?我们需要限制每个点一个父亲(除开根节点),每个点最多两个儿子。 然后我们拆点: S到每个点的出点,流量为2,保证最多两个儿子。 每个点的入点到T,流量为1,保证每个点一个父亲。 对于能到更小的y值,流量为1,费用为两点之间的距离。 最后MCMF即可。 AC代码: #pragma GCC optimiz...

青烟绕指柔的博客 500

Nacos 2.3.2与PostgreSQL的Docker化部署实战

本文详细介绍了Nacos 2.3.2与PostgreSQL的Docker化部署实战,包括环境准备、数据库配置、镜像获取与导入、容器部署及常见问题排查。通过Docker容器化技术,结合PostgreSQL的稳定性和扩展性,为微服务架构提供高效的服务发现和配置管理解决方案。

k5l6m的博客 289

CodeForces960DFull Binary Tree Queries(二叉树的操作)

Full Binary Tree QueriesYou have a full binary tree having infinite levels.Each node has an initial value. If a node has value x, then its left child has value 2·x and its right child has value 2·x + ...

nka_kun的博客 713

别再为数据发愁:5分钟理解事件相机原理,并自己动手生成事件图像

本文深入浅出地解析了事件相机的工作原理,并提供了从静态图像生成事件数据的实用方法。通过Python代码示例,读者可以快速掌握如何模拟事件相机的输出,应用于机器人导航、自动驾驶等领域,解决数据获取难题。

weixin_31458015的博客 308

AutoCAD2014与ObjectARX开发环境搭建实战指南

本文提供了一份详细的AutoCAD2014与ObjectARX开发环境搭建实战指南。内容涵盖从AutoCAD2014、Visual Studio 2010及ObjectARX 2014 SDK的版本匹配与环境准备,到Wizard安装、编码问题解决、Visual Studio配置,并最终通过一个完整的绘图命令开发示例,手把手引导开发者创建并加载第一个可运行的ObjectARX插件,为后续深入开发奠定坚实基础。

weixin_28475533的博客 292

codeforces——————ko

【代码】codeforces错题。

2303_79552392的博客 202

【python数据挖掘课程】二十八.基于LDA和pyLDAvis的主题挖掘及可视化分析

这是《Python数据挖掘课程》系列文章,前面很多文章都讲解了数据挖掘、机器学习,这篇文章主要讲解LDA和pyLDAvis算法,同时讲解如何读取CSV文本内容进行主题挖掘及可视化展示。文章比较基础,希望对你有所帮助,提供些思路,也是自己教学的内容。推荐大家购买作者新书《Python网络数据爬取及分析从入门到精通(分析篇)》,如果文章中存在错误或不足之处,还请海涵。 目录: 一.显示结果及安装 二.LDA主题挖掘 三.pyLDAvis可视化分析 四.小结

杨秀璋的专栏 1万+

【CodeForces - 697C】Lorenzo Von Matterhorn(二叉树,思维)

题干: 巴尼住在NYC。NYC具有从1开始的正整数编号的无数个交叉点。在交叉点i和2i之间以及i和2i + 1之间存在双向道路,对任意整数i都满足。在任意两点之间都有且只有一条最短路。 最初任何人都可以通过任何道路免费。 但是后来发生了 q 个事件。 有两种类型的事件: 1. 政府制定新规。 一个规则可以用三个整数表示v,u和w。经过这次操作,点u到点v...

xuanweiace的博客 692

点云从入门到精通技术详解100篇-基于点云语义分割的电力线提取及聚类研究

在现代社会,电力一直扮演着最重要的角色之一。它不仅与人民的生活息息相关,更是一个国家发展的命脉。近年来,随着我国各特高压输电线路建成(比如2022年1月份白鹤滩江苏特高压输电线路的放线)以及电网规模的不断扩大,我国年发电量稳步上升,人民的生活水平越来越高。我国土地辽阔,输电线路分布广泛,再加上地形环境复杂多样,电力线可能遭受风吹雨晒甚至是冰雪寒灾的影响。因此,为了保障电力线的可靠供电,防止停电意外发生,电力部门要定期对输电线路进行检查。目前我国主要。

getusushu的博客 1014

【Pix4d精品教程】Pix4d空三后处理:点云分类与过滤、DSM精编生成DEM、生成等高线案例详解

本文详细介绍了利用Pix4D软件进行无人机摄影测量后处理的关键步骤,主要包括点云分类与分配、DEM精编生成和等高线绘制三个核心环节。首先通过点云分类区分地面、植被等7种地物类型,然后通过点云分配将地面点云归并到Ground类别,剔除植被等干扰要素。随后重新运行DSM生成步骤获取精确DEM,最后在附加输出中设置参数生成标准等高线。文中配有详细的操作截图和注意事项,如处理前需备份原始DSM/DOM数据,并解释了DEM与DSM的本质区别。该教程为无人机摄影测量内业处理提供了完整的解决方案。

智慧空间实验室 1万+

codeforces 722D Generating Sets (二叉树 + 贪心)

解题思路: 可以根据题中所给的操作构造出一个二叉树,题目中要求的就是将所有的元素溯源,并且最后得到的值不互相重复的序列。并且要求所得序列的最大值最小,所以考虑贪心的想法,每一次对最大的值进行操作,将它上升到与他在同一条链上最近的无重叠元素的点,用set判断当前节点的值是否存在,循环对这个set内的元素进行操作,直到最大的一个元素无法被操作截至。 AC代码: #include using n

wchhlbt的博客 873

基于ZYNQ PL的AD7606数据采集与FFT实时频谱分析:从硬件到创新实现

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kKnmpgJm-1750295287594)(https://example.com/fft_plot.png)]本文涉及代码已在Xilinx ZCU102开发板与AD7606评估板上验证通过,采样率支持200KSPS@8通道,FFT计算延迟<1ms。传统MCU+DSP方案难以兼顾速度与功耗,而ZYNQ的PL+PS架构为这一问题提供了完美解决方案。本文实现的ZYNQ PL方案突破了传统处理器的性能瓶颈,通过。

QQ_778132974的博客 346

Codeforces 697C Lorenzo Von Matterhorn 题解

Codeforces 697C题解

DarkoDu的博客 675

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Codeforces-697C Lorenzo Von Matterhorn

Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road betwe

Wilbert的博客 1733

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (map离散化)

Problem: Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (map离散化) Analyse: 题意不赘述,根据题意可以构造出一个以11为根节点的二叉树。 然后我们用dp[0][i]dp[0][i]表示以ii为父亲节点,发出的连向它的左二子的边的长度。dp[1][i]dp[1][i]表示以ii为父亲节点,连到右儿子的长度。

JIBANCANYANG 549

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

CodeForces 697C Lorenzo Von Matterhorn

题意:有q个节点构成二叉树,有两种输入,第一种是1 v u w,代表是从v节点走到u节点需要w元。第二种是2 v u,代表是从v节点走到u节点,并且输出所需的钱。 思路:看到这道题的时候发现1 ≤ v, u ≤ 1018,这两个数特别大,感觉会用到map去存。另一个难点就是怎么去判断v节点和u节点是否在1的两侧或同侧。判断方法就是,先比较v,u两个点的大小,再将大的那个节点除以二(就一定是它的父...

JTY的博客 525

【CodeForces 697C】Lorenzo Von Matterhorn(LCA)

Least Common Ancestors 节点范围是1~1e18,至多1000次询问。 只要不断让深的节点退一层(>>1)就能到达LCA。 用点来存边权,用map储存节点和父亲连边的权值。 #include<cstdio> #include<map> #define ll long long using namespace std...

dingguayi7025的博客 212

Lorenzo Von Matterhorn【Codeforces 697 C】【map + 模拟LCA过程】

Codeforces Round #362 (Div. 2) C 题目说,每个点(价值为i的点)的下面的两个点分别是“2 * i”和“2 * i + 1”,那么不就是一个二叉树的嘛?这样子就算N、M是1e18,那样的每次找最近公共祖先结点的复杂度也不过是log2(1e18)而已。所以我们可以直接把这条链上的每一条边给加上权值,查询也是一样的操作,因为Q只有1000次,所以,我们用个map维护...

既然弱小,就只顾变强就是了 425

【 Codeforces Round #362 C】Lorenzo Von Matterhorn(思维)

题意: 巴尼住在NYC。NYC具有从1开始的正整数编号的无数个交叉点。在交叉点i和2i之间以及i和2i + 1之间存在双向道路,对任意整数i都满足。在任意两点之间都有且只有一条最短路。 最初任何人都可以通过任何道路免费。 但是后来发生了 q 个事件。 有两种类型的事件: 1. 政府制定新规。 一个规则可以用三个整数表示v,u和w。经过这次操作,点u到点...

__似水流年__的博客 285

Codeforces697C Lorenzo Von Matterhorn

Lorenzo Von Matterhorn Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i ...

Low Coder的博客 361

codeforces 697C Lorenzo Von Matterhorn(二叉树LCA)

Lorenzo Von Matterhorn Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections

wchhlbt的博客 802

CodeForces 697C——Lorenzo Von Matterhorn(二叉树,map)

C. Lorenzo Von Matterhorn time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Barney lives in NYC. NYC has infin

say_c_box的博客 514

CodeForces 697C Lorenzo Von Matterhorn (二叉树寻径)

C - Lorenzo Von Matterhorn Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 697C Description Barney lives in NYC. NYC

DT2131 610

CodeForces - 697C-Lorenzo Von Matterhorn(有点像LCA,原创

传送门:CodeForces - 697C 原创--原创--原创 第一次自己A了一道感觉有点难度的题; 题意:在一个类似于二叉树的图上,1 : u ,v,w 表示从u到v的所以路都加上w的费用;                 2 : u,v 输出u,v间的花费; 思路:自己看这个图,一直想写线段树,后来想想LCA求最近公共祖先,一步一步向上跳的思想还可以,    就用 每个点 ...

weixin_30918633的博客 321

CodeForces 697C. Lorenzo Von Matterhorn(二叉树+map)

题目:http://codeforces.com/problemset/problem/697/C 题意: 一颗二叉树; 操作1:u-&gt;v路径上所有边权值+w 操作2:计算u-&gt;v路径权值和 分析: 一开始写了状压,毕竟深度最多60,0向左走,1向右走,写太长了放弃了。 然后,考虑到q很小,只有1e3,实际上有用的边也很少; 所有,直接用map存边权。 代码: ...

OI -> ACM -> AI 1195
上一篇: PAT (Advanced Level) Practise 1015. Reversible Primes (20) 素数筛法 进制转换
下一篇: hdu5723 Abandoned country
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址