[血压游戏] (https://ac.nowcoder.com/acm/contest/5278/G) 神奇的tag数组...,巧妙弥补了高度损失. 方法一:dsu on tree 类似长链剖分,不过是用unordered_map 来维护高度相关信息,swap复杂度是O(1) #include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf = 0x3f3f3f3f; #define dbg(x..…
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛 × Problem A A simple problem (求N % 1 + N % 2 + ....+ N % N, 待补) ? Problem B Path √ Problem C Range (单调栈) √ Problem…
"华为杯" 武汉大学21级新生程序设计竞赛 https://ac.nowcoder.com/acm/contest/31620#question D.和谐之树 思路:披着线段树外皮的二分.把区间逐层二分.注:要统计能到达的深度,深度相同时优先走右边(比赛的时候就是因为这个没过) 代码 #include <iostream> #include <algorithm> using namespace std; typedef long long ll; int t;…
题目链接 2018广东工业大学校赛 Problem B 考虑到每条边的权值变化$26$个时刻之后一定会回到原来的状态. 那么预处理出前$26$个时刻每棵树的形态,对每棵树做一遍字符串哈希. 查询的时候找到满足$x$往上爬$k$步和$y$往上爬$k$步之后面对的边的边权不一样的时候的$k$的最小值. 那么比较这条不一样的边的权值就好了.这个过程用倍增实现即可. 时间复杂度$O(nlogn)$ #include <bits/stdc++.h> using namespace std; #def…
比赛链接:http://acm-software.hrbust.edu.cn/contest.php?cid=1082 A.好SB啊真是,还以为lis-数有多少个数不一样. #include <bits/stdc++.h> using namespace std; typedef long long LL; ; int ret; int n; set<int> s; int main() { // freopen("in", "r", std…
Problem Description The famous "Alice and Bob" are playing a game again. So now comes the new problem which need a person smart as you to decide the winner. The problem is as follows: They are playing on a rectangle paper, Alice and Bob take tur…
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people are excited, ii and gg are no exception. After watching the game, the two of them also want to play a game. There is now an infinite chessboard with on…
这是跟学长学姐组队来打的最爽的一次比赛了,也可能是互相组队最后一次比赛了,南哥和楼学姐,省赛之后就退役了,祝他们能考研和面试都有happy ending! 虽然最后没有把F题的n^2约数的数学题写完,但体验了好久没有思考尽力的感觉,超级超级棒!! A:跳台阶 签到题:直接输出1<<(n-1) #include<bits/stdc++.h> using namespace std; typedef long long LL; int main(){ int t,n; cin>&…