2019icpc徐州网络赛_I_query】的更多相关文章

题意 给定一个序列,多次询问区间\([l,r]\)中满足\(min(a[i],a[j])==gcd(a[i],a[j])\)的数对\((i,j)\)数. 分析 其实就是求区间有倍数关系的数对数. 由于序列是全排列,所有有倍数关系的数对数只有\(nlogn\)个,因此可以暴力求出所有数对,然后对询问离线,转化为二位偏序的问题,使用树状数组解决即可. 树状数组求逆序对其实就是求\(i<j \&\& a[i]>a[j]\)的二维偏序关系,而在这题里求的就是\(l[i]<l[j]…
题意 有一堆石子,两个顶尖聪明的人玩游戏,先取者可以取走任意多个,但不能全取完,以后每人取的石子数不能超过上个人的两倍.石子的个数是通过模方程组给出的. 题目链接 分析 斐波那契博弈有结论:当且仅当石子数为斐波那契数时,先手必败. 又因为 $n \leq 10^{15}$,在这个范围内的斐波那契数只有72个,可以预处理出来. 注意会爆long long !! #include<iostream> #include<cstdio> #define LL __int128 using…
A Who is better? 题意 excrt+斐波那契博弈 分析 Java的BigInteger对象默认为null,不能直接比较. 代码 import java.math.BigInteger; import java.util.Scanner; public class Main { static int n; static BigInteger[] a=new BigInteger[25]; static BigInteger[] b=new BigInteger[25]; stati…
2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution 将环变成链,设\(f[i][0\)~\(2]\),分别表示与第一个数相同,与第一个数不同,与第一个数相同,与第一个数的反相同.然后\(dp\)即可. 时间复杂度:\(O(n)\) B. BE, GE or NE solution 根据题目描述\(dp\)即可. 时间复杂度:\(O(nm)\) C.…
线段树+单调栈+前缀和--2019icpc南昌网络赛I Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the inter…
query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be represented as a pair (l ,r )(l,r), you need to find the number of pair(i ,j)(i,j) such that l \le i < j \le rl≤i<j≤r and \min(p_i,p_j) = \gcd(p_i,p_j )…
2019ICPC南京网络赛A题 The beautiful values of the palace https://nanti.jisuanke.com/t/41298 Here is a square matrix of n * nn∗n, each lattice has its value (nn must be odd), and the center value is n * nn∗n. Its spiral decline along the center of the squar…
ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才反应过来没看完全部题, J题树形dp没写太亏了... // 几何旋律AK了,太强了Orz // 虽然我们队A了8题,但如果时间分配好,认真读题避免看错题的话,应该至少多A一题 A. Who is better? 题意 两个人玩游戏,谁先消灭完敌人就赢.两条规则:1. 第一个人不能全部消灭完: 2.…
[徐州网络赛]Longest subsequence 可以分成两个部分,前面相同,然后下一个字符比对应位置上的大. 枚举这个位置 用序列自动机进行s字符串的下标转移 注意最后一个字符 #include <bits/stdc++.h> const int maxn = 1e6 + 7; using namespace std; #define ll long long int n, m; char s[maxn], t[maxn]; int nex[maxn][27]; void init()…
In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named "Sena" are playing a video game. The game system of this video game is quite unique: in the process of playing this game, you need to constantly fac…
After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a Nogaku show during the feast. To enjoy the show, every audience has to wear a Nogaku mask, and seat around as a circle. There are N guests Reimu serv…
After the long vacation, the maze designer master has to do his job. A tour company gives him a map which is a rectangle. The map consists of N \times MN×M little squares. That is to say, the height of the rectangle is NN and the width of the rectang…
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xx , yy ) means the wave is a rectangle whose vertexes are ( 00 , 00 ), ( xx , 00 ), ( 00 , yy ), ( xx , yy ). Every time the wave will wash out the trace of…
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i]. Unfortunately, the longer he learns, the fewer he gets. That means, if he reads books from ll to rr, he will get a…
Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat movement from a cat video. To do this, he extracts cat features in each frame. A cat feature is a two-dimension vector <xx, yy>. If x_ixi​= x_jxj​ and y_iy…
54.19% 2000ms 262144K Morgana is playing a game called cacti lottery. In this game, morgana has a 3 \times 33×3 grid graph, and the graph is filled with 11 ~ 99 , each number appears only once. The game is interesting, he doesn't know some numbers, b…
BE, GE or NE 23.58% 1000ms 262144K   In a world where ordinary people cannot reach, a boy named "Koutarou" and a girl named "Sena" are playing a video game. The game system of this video game is quite unique: in the process of playing…
Features Track 31.32% 1000ms 262144K   Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat movement from a cat video. To do this, he extracts cat features in each frame. A cat feature is a two-dimension vecto…
Hard to prepare 28.63% 1000ms 262144K   After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a Nogaku show during the feast. To enjoy the show, every audience has to wear a Nogaku mask, and seat around as…
F. The Answer to the Ultimate Question of Life, The Universe, and Everything. 我的第一道真·打表题 这次是真的打表啊,不是初始化求值! 重现赛的时候,一直在搞在线的做法,map和unordered_map都上了,都是TLE,初始化建立两个map,然后枚举a,b再找是否有c,我算的复杂度也就  O(T*5000*10000/2)?  2e8?好像确实得T.实际复杂度或许更高 ? unordered_map内部哈希表实现,…
这个题,我也没想过我这样直接就过了 #include<bits/stdc++.h> using namespace std; ; typedef pair<int,int> pii; set<pii> G[maxn]; int main(){ int t,n,m,a,b,maxl; scanf("%d",&t); ;e<t;e++){ maxl=; ;i<maxn;i++)G[i].clear(); scanf("%d&…
题意:n个左下角为原点右上角在第一象限的矩形不断覆盖,求最后形成的图形的周长 x和y是独立的,分别维护两棵线段树,一棵表示x坐标下最大的y值,另一棵表示y坐标下最大的x值 从覆盖的角度来考虑,如果逆序处理,当前处理的段的贡献为大于等于当前位置的最大值的差 比如一条横的线段i,坐标为[x1=0,x2],y 那它对答案的贡献为max(0,x2 - max_x of [y,maxy]),此时的区间存在的线段为逆序第n条到第i+1条 处理完后再插入到对应的线段树中即可(其实贡献为0的不插也行,因为都是不…
死于update的一个long long写成int了 真的不想写过程了 ******** 树状数组,一个平的一个斜着的,怎么斜都行 题库链接:https://nanti.jisuanke.com/t/31460 #include <iostream> #include <cstring> #define ll long long #define lowbit(x) (x & -x) using namespace std; ; int n, m; ll t[maxn]; l…
题目链接: https://nanti.jisuanke.com/t/31458 题解: 建立两个树状数组,第一个是,a[1]*n+a[2]*(n-1)....+a[n]*1;第二个是正常的a[1],a[2],a[3]...a[n] #include "bits/stdc++.h" using namespace std; #define ll long long const int MAXN=1e5+10; ll sum[MAXN],ans[MAXN]; ll num[MAXN];…
Problem A Problem B Problem C. 首先枚举那些他知道但是我不知道的数字.枚举这些的所有情况. 然后对每种情况再枚举我们都不知道的数字.求出每行每列的期望,求个最大值. 这样就得到了那种情况的最大期望值. 对所有情况的最大期望值求平均值就可以了. Problem D Problem E Problem F Problem G 根据题目条件我们得到任意两个矩形长宽都是不同的. 这样的话就很简单了. 对每一条线段求个真实的显示长度. 做两次线段树就可以了. Problem…
题意 题意不明,队友告诉我对于每个\(i\),所在下标\(p[i]\),在\([p[i]-k,p[i]+k]\)中找到小于\(i\)的最大数\(x\),然后\(ans[i]=ans[x]+1\)即可. 分析 第一种方法无脑主席树,求区间小于某个值的最大数. 第二种方法是线段树,因为对于每个数\(i\),只有比他小的数才有用,所以从小到大枚举,在线段树中(此时所有值都小于\(i\)),查询区间最大值即可. 代码 code1 #include <bits/stdc++.h> using names…
题意 给定一个序列,两种操作,单点修改,询问区间\([l,r]\)值域在\([x,y]\)范围内的连续段个数. 分析 原数组为\(a\),构造一个新的数组\(b\),\(b[i]=(a[i]==a[i-1])?0:a[i]\),这样将连续段转化为左端点的一个数来表示. 询问就可以转化为维护\(b\)数组,单点修改和询问区间在某个值域内的数的个数,用树状数组套权值线段树. 类似于差分的思想,对于询问\(l,r\),我们要查询的是\(b\)数组的\([l+1,r]\),因此会漏掉\(a[l]\)这个…
题意: 给了一个母串S, 每次循环给了一个模板串,问模板串在母 串中“匹配”了多少次?“匹配”的意思就是首字母和尾字母一样, 中间字母顺序可以换. 题解: 字符串hash.我们将询问字符串的首尾特殊hash,然后将询问串的长度存入到vector里面. 然后遍历一遍原串,将所有是询问串长度的子串的哈希值插入到vecor并排序,然后对于该询问,我们只要用lower_bound和upper_bound查找有多少哈希值等于我的就行了,记录答案,最后输出答案. 参考代码: #include<bits/st…
I. query 比赛时候没有预处理因子疯狂t,其实预处理出来因子是\(O(nlog(n))\)级别的 每个数和他的因子是一对偏序关系,因此询问转化为(l,r)区间每个数的因子在区间(l,r)的个数 预处理出来每个位置上的数所有因子的位置,用可持久化线段树维护,区间询问 #include<bits/stdc++.h> #define ll long long #define mk make_pair #define ft first #define se second #define pii…
题意: 先有\(n=p_1^{k_1}p_2^{k_2}\cdots p_m^{k_m}\),定义\(f(n)=k_1+k_2+\cdots+k_m\). 现在计算 \[ \sum_{i=1}^nf(i!)\% 998244353 \] 思路: 首先注意到\(f\)函数有这样一个性质:\(f(ab)=f(a)+f(b)\). 那么我们化简所求式子有: \[ \begin{aligned} &\sum_{i=1}^nf(i!)\\ =&\sum_{i=1}^n\sum_{j=1}^if(j)…