Bubble Sort Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 224    Accepted Submission(s): 147 Problem Description P is a permutation of the integers from 1 to N(index starting from 1). Here is…
Description ?? is practicing his program skill, and now he is given a string, he has to calculate the total number of its distinct substrings. But ?? thinks that is too easy, he wants to make this problem more interesting. ?? likes a character X very…
题目大意:一个n(n<=1000)行,20列的棋盘上有一些棋子,两个人下棋,每回合可以把任意一个棋子向右移动到这一行的离这个棋子最近的空格上(注意这里不一定是移动最后一个棋子),不能移动到棋盘外,不能移动了就算输,两个人都用最优策略,问先手是否有必胜策略. 这题显然就是SG函数了吧.行与行之间互不影响,所以可以看成n个子游戏,求出它们各自的SG函数然后异或一下就可以了.我们发现只有20列,2^21=2097152,所以我们可以先把行的所有情况的SG函数预处理出来,然后每次询问O(1)就行了. 代…
暑假颓废了好久啊...重新开始写博客 题目大意:给定10w个数,10w个询问.每次询问一个区间[l,r],求出gcd(a[l],a[l+1],...,a[r])以及有多少个区间[l',r']满足gcd(a[l'],a[l'+1],...,a[r'])==gcd(a[l],a[l+1],...,a[r]). 第一问就是简单的ST表了,f[i,j]表示i~i+2^j-1的gcd是多少,预处理出来就可以O(1)查询了. 第二问需要分析一下.首先,对于任意一个左端点,显然随着右端点的右移,这个区间的gc…
Is Derek lying? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 612    Accepted Submission(s): 353 Problem Description Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.Thi…
描述 LT最近一直在无限循环薛之谦的歌,简直都中毒了!可是呢…他的歌LT还是不会唱(其实不止他的歌LT不会唱,所有人的歌LT都不会唱…因为LT是标准的音痴)可是LT又很喜欢唱歌(所以LT不仅是音痴还是音痴)…没错,这对于LT的室友来说简直是噩梦… 现在呢,LT有N次操作,每次操作只会有两种可能: I a: 表示着LT使用唱歌软件唱歌得到的分数. Q k: 表示着LT想知道自己得到的第k小的分数是多少.(如果没有第k小,输出-1)   输入 有多组输入(不超过20组),每组输入的第一行是一个N,表…
题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and its coordinate is (xi,yi). It is guaranteed that no two points have the same coordinate, and no two points makes the line which passes them also passes…
题目链接 Problem Description Give an array A, the index starts from 1. Now we want to know Bi=maxi∤jAj , i≥2. Input The first line of the input gives the number of test cases T; T test cases follow. Each case begins with one line with one integer n : the…
题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix, I randoml…
题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make. Input The input file consists of several test cases. Each case the first line is a…
题目链接 Problem Description Steph is extremely obsessed with "sequence problems" that are usually seen on magazines: Given the sequence 11, 23, 30, 35, what is the next number? Steph always finds them too easy for such a genius like himself until o…
题意很简单啦,求S(n,m)的值 通过打表我们可以知道 S(n + 1, m) = S(n, m) * 2 - C(n, m); S(n - 1, m) = (S(n, m) + C(n - 1, m)) / 2; 首先我们考虑杨辉三角和二项式定理,但是看了看数据情况,貌似时间不允许呢 这个时候就要祭出莫队算法啦,关于莫队算法呢,更详细的理解请看:2010国家集训队<小Z的袜子>命题报告 莫队算法是一种用于解决可离线的,求区间[L,R]问题的算法 这个题当然就可以离线去求啦,莫队算法在解决离线…
题目链接 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to z into each number ranged from 0 to 25, but each two differen…
本题题意是,给你一个长度为n的序列,使用最少的操作把序列转换为从小到大的顺序,并输出操作数*min(x,y) 实质上是算出该序列中有多少逆序对,有归并排序和树状数组两种算法,由于数据之间的差值有点大,所以使用树状数组时需要先离散化 离散化后排序有两种方式,一种是先按value排,再按id排,另一种是按value排后,把重复的统一化 这里采用第一种方式 Swaps and Inversions Time Limit: 2000/1000 MS (Java/Others)    Memory Lim…
这个题的题意是给你n个字符串,认定()是一种平衡的串,两个以上连续的()()也是一种平衡的串,如果一对括号里面包含一个平衡的串,这个括号也被算在这个平衡的串之内, 如(()(()))是一个长度为8的平衡字符串,让你通过对给的n个串进行排序,组成一个新的串,问其中平衡串的最大长度是多少 这个题的重点是在对这些串排序规则的制定(本鶸连要排序都想不到) 如果要得到一个最长平衡串的串 需要遵循以下几点规则 注:左为'(',右为')' 1.左多右少的串在右多左少的左边 2.左少右多和左少右多排序时,左括号…
题意是给3n个点,其中不可能存在任意三点共线的情况,让你在其中建n个三角形,点不能重复使用,三角形不能相互覆盖 做法是给每个点排序,按照先y轴排,再x轴排的顺序,三个三个一组从下往上输出,有人说是凸包,其实没那么麻烦 Problem Description Chiaki has 3n points p1,p2,…,p3n. It is guaranteed that no three points are collinear.Chiaki would like to construct n di…
The sum of gcd Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 23    Accepted Submission(s): 4 Problem Description You have an array A,the length of A is n Let f(l,r)=∑ri=l∑rj=igcd(ai,ai+1....a…
题面传送门 一道非常不错的 FWT+插值的题 %%%%%%%%%%%% 还是那句话,反正非六校的看不到题对吧((( 方便起见在下文中设 \(n=2^d\). 首先很明显的一点是这题涉及两个维度:异或和与选出的元素的个数.因此考虑像子集卷积那样建立一个二元生成函数表示这个东西,具体来说我们定义一个幂级数 \(F\)​​ 形如 \(\sum\limits_{n\ge 0}\sum\limits_{m\ge 0}f_{n,m}x^ny^m\)​​,并定义两个幂级数 \(F,G\)​​ 的乘法得到的幂级…
由于 NFLSOJ 题面上啥也没有就把题意贴这儿了( 没事儿,反正是上赛季的题,你们非六校学生看了就看了,况且看了你们也没地方交就是了 题意: 给你一张 \(n\) 个点 \(m\) 条边的图 \(G=(V,E)\). 要求有多少张子图 \(G'=(V',E')\)​ 满足 \(G'\) 是连通二分图. \(n\le 20,m\le\dfrac{n(n-1)}{2}\) 答案对 \(998244353\) 取模. 输入样例 #1: 3 3 1 2 1 3 2 3 输出样例 #1: 9 众所周知,…
本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> using namespace std; char s[3][30]; int player…
这题起初没读懂题意,悲剧啊,然后看了题解写完就AC了 题意是给一个N,然后给N+1个整数 接着给N个操作符(只有三种操作  即  或 ,与 ,和异或 |   &  ^ )这样依次把操作符插入整数之间就可以得到一个表达式 接着给出 N 给浮点数(在0~1之间表示概率 )表示的是 操作符和他右边的整数丢失的概率. 例如下面这组数据 1 1 2 & 0.5 整数与操作符间可以组成一个表达式即 1&2 但是由于某些原因表达式的操作符和他操作的右边的 那个数有一定的概率会丢失这组数据就是 &…
题目连接:Click here 题意:在一个[L,R]内找到最大的gcd(f[i],f[j])其中L<=i<j<=R,f[x]表示i分解质因数后因子的种类数.eg:f[10]=2(10=2*5),f[12]=2(12=2*2*3). 分析:很容易想到先将f[x]求出来,这里x最大1e6,要在常数时间内求出f[x].并且稍加分析就知道1<=f[x]<=7,可以用一个dp[i][j]表示从f[1]到f[i]有多少个j.这样就可以在常数时间内预处理出来,后面在O(1)的时间内就可以…
题目连接:戳ME #include <iostream> #include <cstdio> #include <cstring> using namespace std; ; int n, k; int par[M]; int sum[M]; void find(int x) { if( par[x]!=x ) { sum[par[x]]++; find(par[x]); } else return; } int main() { while( ~scanf(&quo…
点击打开链接 我就不说官方题解有多坑了 V图那么高端的玩意儿 被精度坑粗翔了 AC前 AC后 简直不敢相信 只能怪自己没注意题目For the distance d1 and d2, if fabs(d1-d2)<1e-7, we think d1 == d2 有空再补充V图的做法吧..本人也是第一次接触V图 //大白p263 #include <cmath> #include <cstdio> #include <cstring> #include <se…
描述  有N个人,N个活动, 每个人只会对2个或者3个活动感兴趣,  每个活动也只有两个人或者两个活动对它兴趣,每个人参加一个  感兴趣的活动需要一天 ,且当天该活动被参加时,其他的人不能参加  如果每个人都参加完自己有兴趣的活动,应当怎样安排使得所用总天数时间最短 2<= N <=1000, 1<=m<=1000;   输入 一个数T 表示T 组数据每组一个N表示人数,编号1 -- N , 一个数 m ,接下来m 行每个两个数x,y, 表示第 x 个人对第y个活动感兴趣 输出 每…
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes:…
题目链接 Problem Description Giving two strings and you should judge if they are matched. The first string contains lowercase letters and uppercase letters. The second string contains lowercase letters, uppercase letters, and special symbols: "." an…
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2. LsF wants to make some trouble. While zk is sleeping, Ls…
题目链接 Problem Description The Eternal Fleet was built many centuries ago before the time of Valkorion by an unknown race on the planet of Iokath. The fate of the Fleet's builders is unknown but their legacy would live on. Its first known action was in…
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-si…