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…
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…
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\)…
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的父亲节点变…
计蒜客题目链接:https://nanti.jisuanke.com/t/41387 题目大意:给定一组无序序列,从第一个数开始,求最远比这个数大m的数,与这个数之间相隔多少数字?如果没有输出-1,否则输出间隔了多少数字. 题解:从后往前遍历,在遍历的同时维护一个递增队列,若当前的数大于队尾就进队,否则从该队列中二分找最小的比自己大至少  的数,二者之间的距离即为答案,这里我用vector模拟这个队列.若当前数小于队尾,那这个数一定没有队尾的数优,因为它既比队尾的数靠前,又比它小. AC代码:…