It is my great honour to introduce myself to you here. My name is Aloysius Benjy Cobweb Dartagnan Egbert Felix Gaspar Humbert Ignatius Jayden Kasper Leroy Maximilian. As a storyteller, today I decide to tell you and others a story about the hero Huri…
Duha decided to have a trip to Singapore by plane. The airplane had nn seats numbered from 11 to nn, and nn passengers including Duha which were also counted from 11 to nn. The passenger with number ii held the ticket corresponding to the seat with n…
Firdaws and Fatinah are living in a country with nn cities, numbered from 11 to nn. Each city has a risk of kidnapping or robbery. Firdaws's home locates in the city uu, and Fatinah's home locates in the city vv. Now you are asked to find the shortes…
2019 ICPC 南昌网络赛 比赛时间:2019.9.8 比赛链接:The 2019 Asia Nanchang First Round Online Programming Contest 总结 // 史上排名最高一次,开场不到两小时队友各A一题加水题共四题,排名瞬间升至三四十名 // 然后后三小时就自闭了,一题都没有突破...最后排名211 hhhh     B. Fire-Fighting Hero 题意 队友做的,待补.   AC代码 #include<cstdio> #includ…
题目: 给定一棵树, 带边权. 现在有2种操作: 1.修改第i条边的权值. 2.询问u到其他一个任意点的最大距离是多少. 题解: 树的直径可以通过两次 dfs() 的方法求得.换句话说,到任意点最远的点,一定是直径的某个端点(反证法). • 因此原问题转化为动态维护直径,然后再支持询问两个点的距离,后者可以 dfs 序 + lca + 树状数组. 参考代码: #include<bits/stdc++.h> #define lowbit(x) (x&-x) #define lson l,…
Problem Similar to the strange ability of Martin (the hero of Martin Martin), Ghh will random occurrence in one of \(N\) cities every morning and the money will change to \(X\) RMB (No matter how much money had yesterday). Ghh finds that every \(N\)…
You're given a permutation aa of length nn (1 \le n \le 10^51≤n≤105). For each i \in [1,n]i∈[1,n], construct a sequence s_isi​ by the following rules: s_i[1]=isi​[1]=i; The length of s_isi​ is nn, and for each j \in [2, n]j∈[2,n], s_i[j] \le s_i[j-1]…
Yukino With Subinterval Yukino has an array a_1, a_2 \cdots a_na1,a2⋯*a**n*. As a tsundere girl, Yukino is fond of studying subinterval. Today, she gives you four integers l, r, x, yl,r,x,y, and she is looking for how many different subintervals [L,…
英雄灭火问题忽略了一点丫 一个超级源点的事情,需要考虑周全丫 2 #include<cstdio> #include<cstring> #include<queue> #include<vector> #include<iostream> #include<algorithm> using namespace std; #define maxn 1010 #define INF 0x3f3f3f3f int T, n, m, s, k…
计蒜客链接:https://nanti.jisuanke.com/t/41384 题目大意:给定n个数,从1到n排列,其中有q次操作,操作(1) 删除一个数字 // 操作(2)求这个数字之后第一个没有被删除的数字(包括自己). 题解:考虑到实践复杂度问题,n范围是1e9,而q的范围是1e6,所以可以从q入手.用并查集的思路模拟出一个链表,用hashmap存储一个数距离它最近没有被删除的数(即并查集的父亲节点),初始化每个点的map的value存储下一个没有被删除的点,若删除一次,则x的父亲节点变…