2019 ICPC 沈阳网络赛 J. Ghh Matin】的更多相关文章

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\)…
2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex Hull 题目描述:定义函数\(gay(x)\),若\(x\)是某个非\(1\)的数的平方的倍数,则\(gay(x)=0\),否则\(gay(x)=x^2\),求\(\sum_{num=1}^{n} ( \sum_{i=1}^{num} gay(x) ) mod p\) solution \[\sum…
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…
题意:给出一棵树,给出每条边的权值,现在给出m个询问,要你每次输出u~v的最短路径中,边权 <= k 的边有几条 思路:当时网络赛的时候没学过主席树,现在补上.先树上建主席树,然后把边权交给子节点,然后数量就变成了 u + v - lca * 2.专题里那道算点权的应该算原题吧.1A = =,强行做模板题提高自信. 代码: #include<cmath> #include<set> #include<map> #include<queue> #incl…
边权转点权,每次遍历到下一个点,把走个这条边的权值加入主席树中即可. #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> using namespace std; ; struct node{ int l,r,cnt; }tree[maxx*]; int head[maxx],rk[maxx],siz[maxx],top[maxx],son[maxx],d[m…
cable cable cable Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 278    Accepted Submission(s): 224 Problem Description Connecting the display screen and signal sources which produce different…
1000ms 262144K   DSM(Data Structure Master) once learned about tree when he was preparing for NOIP(National Olympiad in Informatics in Provinces) in Senior High School. So when in Data Structure Class in College, he is always absent-minded about what…
计蒜客题目链接:https://nanti.jisuanke.com/t/41303 题目:给你一个序列a,你可以从其中选取元素,构建n个串,每个串的长度为n,构造的si串要满足以下条件, 1. si[1]=i . 2. si[j]<si[j-1] 3. |pos[j] -pos[j-1]|<=k 并且每个a中的元素只能用一次 4. 两个串大小的定义时 前k项相等的前提(k和前面不是一个),Ck>Dk,则C大于D 求Si的长度,并输出 由于Si[ j ] < Si[j - 1] ,…
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…
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]…
As the current heir of a wizarding family with a long history,unfortunately, you find yourself forced to participate in the cruel Holy Grail War which has a reincarnation of sixty years.However,fortunately,you summoned a Caster Servant with a powerfu…
题意:一个数列,给出这个数列中的某些位置的数,给出所有相邻的三个数字的和,数列头和尾处给出相邻两个数字的和.有若干次询问,每次问某一位置的数字的最大值. 分析:设数列为a1-an.首先通过相邻三个数字的和我们可以求出a3,a6,a9……是多少.a3=sum(a1,a2,a3)-sum(a1,a2).a6=sum(a4,a5,a6)-sum(a3,a4,a5).后面依次类推. 推到了数列的最右面,如果恰好知道了an或者a(n-1)中的一个,那么可以通过sum(an,a(n-1))减去它来求得另一个…
Press the Button Time Limit: 1 Second      Memory Limit: 131072 KB BaoBao and DreamGrid are playing a game using a strange button. This button is attached to an LED light (the light is initially off), a counter and a timer and functions as follows: W…
[传送门]https://nanti.jisuanke.com/t/31452 [题目大意]:给定一个数字(最大可达10100),现在要求不超过它的最大超级质数.超级质数定义:对于一个数,把它看成数字序列 ,如果它的所有子序列形成的数都是质数,那么它就是超级质数. 比如说3137,它的子序列有3,1,7,31,33,37,313,317,137.....由于有一个子序列是33它不是质数,所有3137不是超级质数. [题解]注意,子序列和子串是不同的,子序列包含子串.子序列只要求相对顺序不变,而子…
题目: 给定一棵树, 带边权. 现在有2种操作: 1.修改第i条边的权值. 2.询问u到其他一个任意点的最大距离是多少. 题解: 树的直径可以通过两次 dfs() 的方法求得.换句话说,到任意点最远的点,一定是直径的某个端点(反证法). • 因此原问题转化为动态维护直径,然后再支持询问两个点的距离,后者可以 dfs 序 + lca + 树状数组. 参考代码: #include<bits/stdc++.h> #define lowbit(x) (x&-x) #define lson l,…
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代码:…
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…