CSU 1060 Nearest Sequence】的更多相关文章

题意:求三个序列的最长公共子序列. 思路:一开始以为只要求出前两个的LCS,然后和第三个再求一遍LCS就是答案了.但是样例就对我进行啪啪啪打脸了.实际上就跟两个序列的差不多,换成三维的就行了. 代码:需要注意的是max速度比较慢,最后改成if #include<stdio.h> #include<string.h> #include<iostream> using namespace std; ; int dp[N][N][N]; char a[N],b[N],c[N]…
Inversion Sequence Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1555 Mean: 给你一个序列a[n],要你按照要求去构造一个序列b. 序列a[i]表示序列b中的i前面有a[i]个数比i大. 转换一下就是: 已知一个连续的序列(1,2,3,4,...),然后告诉了我们这个序列中每个数前面比本身大的个数,根据这些条件将这个序列调整顺序,找到满足条件的序列. analyse: STL大法好…
Description A county consists of n cities (labeled 1, 2, …, n) connected by some bidirectional roads. Each road connects a pair of distinct cities. A robot company has built maintenance points in some cities. Now, they need your help to write a progr…
https://vjudge.net/problem/CSU-2005 题意:给出带权值的图,图上有一些特殊点,现在给出q个询问,对于每个询问,输出离该点最近的特殊点,如果有多个,则按升序输出. 思路:因为有多次查询,不可能对于每个询问都去跑一遍最短路.必须以特殊点为起点跑一遍最短路,但是这样路径的记录就是问题了.正解是用bitset来记录状态,在最短路松弛更新状态时,继承前驱节点即可. #include<iostream> #include<algorithm> #include…
并不是很正规的.每个人自愿参与自愿退出,马哥找题(马哥超nice么么哒). 放假第一周与放假结束前一周 2015-01-26 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68304#overview password: scau0126     ID Origin Title   13 / 29 Problem A CodeChef SUBGCD Subarray GCD   8 / 50 Problem B CodeChef SU…
Description For sequence i1, i2, i3, … , iN, we set aj to be the number of members in the sequence which are prior to j and greater to j at the same time. The sequence a1, a2, a3, … , aN is referred to as the inversion sequence of the original sequen…
题意:给n个数,m个询问.每个询问是一个区间,求区间内差的绝对值为1的数对数. 题解:先离散化,然后莫队算法.莫队是离线算法,先按按询问左端点排序,在按右端点排序. ps:第一次写莫队,表示挺简单的,不过这题之前乱搞一气一直TLE,莫队还是很强大的. 代码: #include <algorithm> #include <iostream> #include <cstdio> #include <cmath> #include <cstring>…
莫队算法+map #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<algorithm> using namespace std; +; ],pos[maxn]; struct X { int l,r,id; } s[maxn]; int L,R; int Ans,f[maxn]; bool cmp(const X&a,const X&…
Description 有一个1到N的自然数序列1,2,3,...,N-1,N. 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi] (即第Ai个元素到第Bi个元素之间的一段)取出,然后插入到剩下的第Ci个元素的后面,如果Ci=0,表示插入到最左端. 现在,M次操作完后,有K个询问,每个询问Pi表示询问最终第Pi个元素是几.你的任务是写一个程序,依次回答这K个询问. Input 第一行三个数,N,M,K. 接下来M行,每行三个整数Ai,Bi,Ci. 接下来K行,每行…
Wow! Such Sequence! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3808 Accepted Submission(s): 1079 Problem Description Recently, Doge got a funny birthday present from his new friend, Protein…