A. 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 and another road between i and 2i + 1 for every pos…
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. Ther…
2018-03-16 http://codeforces.com/problemset/problem/697/C 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 intersect…
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 e…
题目链接: A. 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…
http://codeforces.com/contest/697/problem/C 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…
原题链接:http://codeforces.com/contest/696/problem/A 原题描述: 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 a…
A. 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. Ther…
Least Common Ancestors 节点范围是1~1e18,至多1000次询问. 只要不断让深的节点退一层(>>1)就能到达LCA. 用点来存边权,用map储存节点和父亲连边的权值. #include<cstdio> #include<map> #define ll long long using namespace std; map<ll,ll>m; ll u,v,w; void add(){ while(u!=v){ if(u<v){ m…
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽量不用 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #…
题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作是求u到v上的路径和. 我们可以看出任意一个点到1节点的边个数不会超过64(差不多就是log2(1e18)),所以可以找最近相同祖节点的方式写. 用一条边的一个唯一的端点作为边的编号(比如1到2,那2就为这条边的编号),由于数很大,所以用map来存. 进行1操作的时候就是暴力加w至u到LCA(u,v…
A,给一棵完全二叉树,第一个操作,给两个点,两点路径上的所有边权值都增加w,第二个操作,给两个点,求两点路径上的所有边权值和. 我看一眼题就觉得是树链剖分,而我又不会树链剖分,扔掉. 后来查了题解,首先数据范围是1e18不可能是树剖,其次完全二叉树啊!不是普通的树啊!!sb... //我做过此题,没做出来,被学弟教会..虽然我做的题少,但我一向觉得至少自己做过的题都是记得的...但是.... #include <algorithm> #include <iostream> #inc…
题目链接: http://codeforces.com/problemset/problem/696/A 题目大意: 一个满二叉树,深度无限,节点顺序编号,k的儿子是k+k和k+k+1,一开始树上的边权都为0 N(N<=1000)个操作,操作两种,1是从u到v的路径上的所有边权+w,2是求u到v的边权和.(1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109) 题目思路: [STL][模拟] 用map写很快,第一次用很生疏.现学只看了一点点. 因为是满二叉树所以直接暴力求LCA…
方法:求出最近公共祖先,使用map给他们计数,注意深度的求法. 代码如下: #include<iostream> #include<cstdio> #include<map> #include<cstring> using namespace std; #define LL long long map<LL,LL> sum; int Get_Deep(LL x) { ; i < ; i++) { ))>x) ; } ; } void…
http://www.cnblogs.com/a2985812043/p/7224574.html 解法:这是网上看到的 因为要计算u->v的权值之和,我们可以把权值放在v中,由于题目中给定的u.v特性,我们可以从最后一个v开始倒回来每次除以2,然后把权值加起来就好了,注意输入的区间大小值 #include <iostream> #include <cstdio> #include <map> using namespace std; #define LL lon…
题目链接:https://codeforces.com/problemset/problem/697/C 两种操作: 1是对树上u,v之间的所有边的权值加上w 2是查询树上u,v之间的边权和 树是满二叉树,用map存点到其父亲的边权值,对于操作一,当u!=v时我们先更新深度最大的点到其父亲的边权值,再令其等于其父亲,不断循环直至u=v. 操作二与操作一类似 #include<iostream> #include<algorithm> #include<map> #inc…
传送门: CodeForces - 697C 原创--原创--原创 第一次自己A了一道感觉有点难度的题: 题意:在一个类似于二叉树的图上,1 : u ,v,w 表示从u到v的所以路都加上w的费用: 2 : u,v  输出u,v间的花费: 思路:自己看这个图,一直想写线段树,后来想想LCA求最近公共祖先,一步一步向上跳的思想还可以, 就用 每个点 表示这个点到父节点所需要的花费:计算的时候,和求LCA相似,累加到最近公共祖先的花费: 还有就是用map< ll ,  ll >存每个节点的信息: #…
前面说点什么.. 为了完成日常积累,傻逼呵呵的我决定来一发codeforces 挑水题 泛做.. 嗯对,就是泛做.. 主要就是把codeforces Div.1的ABCD都尝试一下吧0.0.. 挖坑0.0.. Codeforces Round #360 A. NP-Hard Problem 就是一个二分图染色,判断是否为二分图而已.. B. Remainders Game 题意:有一个未知的\(x\)和已知\(x\ mod\ c_i\)的值,问是否能确定\(x\ mod\ k\)的值 考虑一下中…
A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time.…
A - Pineapple Incident #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include <cstring> #include <sstream> #include <string> #include <algorithm> #include <li…
很久没有打比赛了,内部模拟赛天天垫底,第一次vp之旅又是和**一样,这样下去GDOI之后直接退役算了 整场都在忘开LL A. Lorenzo Von Matterhorn 这个题一看我就想直接虚树+树剖强行搞,但是这个是A题啊...写着中途看榜已经100+的人A了,冷静思考发现可以暴力计算每个修改对询问的印影响,用树上差分搞搞,两个点的LCA可以用位运算求,反正心态崩着乱推乱玩各种出锅浪费了1h最后给混过去了,不过还是一个很不错的题 #include<cstdio> #include<i…
闲来无事一套CF啊,我觉得这几个题还是有套路的,但是很明显,这个题并不难 A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in…
LCA 倍增法求最近公共祖先 首先对于每个结点先进行dfs预处理它的深度,再记录下它们往父亲方向走2的0次,1次...k次步所到达的结点.在这里2的k次大于整棵树的最大深度. 预处理完后,需要查询两个点u,v的LCA时,先将u,v中深度较大的利用预处理的数组走到和另一个结点相同深度,操作次数不会超过log2|depth(u)-depth(v)| 接下来从k开始往下枚举,如果u和v往上走2的i次后不同那么它们一起往上走那么多步 预处理 O(nlogn)查询O(logn) 不仅如此我们可以动态地给树…
A. Lorenzo Von Matterhorn B.Minimum spanning tree for each edge C.Misha, Grisha and Underground D.Fools and Roads E.City Driving 题意:给你一颗基环树(有n条边,n个点的连通图),有Q个询问,求u,v之间的距离最小是多少 思路:对于一棵基环树而言,只要去掉其环上任意一条边(a , b),其边权为w ,剩下的边就可以构成一棵树 对于 u,v 之间的最小距离 , 有可能由去…
v-bind 指令用于响应地更新 HTML 特性 形式如:v-bind:href    缩写为    :href; v-on 指令用于监听DOM事件 形式如:v-on:click  缩写为 @click; <body> <div id="test"> <img v-bind:src="src"> <a v-bind:href="url">百度一下</a> <a :href=&quo…
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION 3.1 COMPUTER COMPONENTS As discussed in Chapter 2, virtually all contemporary computer designs are based on concepts developed by John von Neumann at the Institute for Adv…
展示Holle Vue     window.onload = function(){         var box = new Vue({             el:'#div',                     data:{             mgs:'Holle vue'}         });     } v-model : 数据绑定(多数用于表单元素)  HTML:   JS:   ps:同时v-model支持双向数据绑定   v-for : 用于元素遍历    …
版权声明:出处http://blog.csdn.net/qq20004604   目录(?)[+]   资料来于官方文档: http://cn.vuejs.org/guide/events.html 本文是在官方文档的基础上,更加细致的说明,代码更多更全. 简单来说,更适合新手阅读     (二十二)方法处理器 ①v-on的标准用法 用于监听DOM事件,典型的就是v-on:click,处理的方法放在methods属性里 会默认传一个参数,代码如下: <button @click="test…
<div id="wrap"> <input type="text" v-on:textInput="fn"> </div> <script type="text/javascript" src="vue.js"></script> <script type="text/javascript"> new Vue({…
绑定事件监听器.事件类型由参数指定.表达式可以是一个方法的名字或一个内联语句,如果没有修饰符也可以省略. 1.事件 .click .mouseover .keyup ...... 2.修饰符 .stop - 调用 event.stopPropagation(). .prevent - 调用 event.preventDefault(). .capture - 添加事件侦听器时使用 capture 模式. .self - 只当事件是从侦听器绑定的元素本身触发时才触发回调. .{keyCode |…