【HDU 1533】 Going Home (KM)】的更多相关文章

Going Home Problem Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel f…
Primitive Roots   Description We say that integer x, 0 < x < n, is a primitive root modulo n if and only if the minimum positive integer y which makes x y = 1 (mod n) true is φ(n) .Here φ(n) is an arithmetic function that counts the totatives of n,…
-->A计划 Descriptions: 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验.魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老.年迈的国王正是心急如焚,告招天下勇士来拯救公主.不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出. 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的位置用P表示,时空传输机用#表示,墙用*表示,平地用.表示.骑士们一进入时空传输机就会被转到另一层的相对…
给定两个数字序列,求a序列中每隔p个构成的p+1个序列中共能匹配多少个b序列. 例如1 1 2 2 3 3 每隔1个的序列有两个1 2 3 kmp,匹配时每次主串往前p个,枚举1到p为起点. 题目 #include<bits/stdc++.h> #define N 1000005 int t,n,m,p; int nex[N]; int a[N],b[N]; using namespace std; void getNext(){ int i=0,k=-1; nex[0]=k; while(b…
空间的200个点,求出至少四边相等,且其余两边必须不相邻的四面体的个数. 用map记录距离点i为d的点有几个,这样来优化暴力的四重循环. 别人的做法是枚举两点的中垂面上的点,再把到中点距离相等的点找出来,n^3的样子. 还要注意四个点共面的情况. 共面判断就是用叉乘计算出ijk三点所在面的法向量,然后判断il向量是否和法向量垂直,是则共面. #include <cstdio> #include <cstring> #include <algorithm> #includ…
高中物理斜抛运动,简单分析一下角度固定下来则可以计算每个cannonball的降落坐标lnd. 因此暴力计算不同角度下的结果. #include <cstdio> #include "cmath" #include "algorithm" #define ll long long #define dd double #define N 205 #define g 9.8 #define eps 1e-6 const dd pi=acos(-1.0); l…
BUPT2017 wintertraining(15) #8D 题意 给你x轴上的N个线段,M次查询,每次问你[l,r]区间里最多有多少个不相交的线段.(0<N, M<=100000) 限时15000 MS 题解 如果不看限时,当作是1000MS的话= =,那么可以用倍增来做. 先按右端点排序. 可以去掉一下包含了其它区间的区间,可以优化一点点. 用 f[i][j] 表示 i 节点下 \(2^n\) 个不相交的线段下标. 预处理出 f 数组. 查询的时候,左端点用二分,然后右端点用倍增来找.…
Problem Description Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell: Suffix(S2,i) = S2[i...len].Ni is the…
Problem Description You may already know that how the World Finals slots are distributed in EC sub-region. But you still need to keep reading the problem in case some rules are different. There are totally G slots for EC sub-region. X slots will be d…
这题数据水的一B.直接暴力都能够过. 比赛的时候暴力过的.回头依照正法做了一发. 匹配的时候 失配函数 事实上就是前缀 后缀的匹配长度,之后就是乱搞了. KMP的题可能不会非常直接的出,可是KMP的思想常常渗透在非常多题目里面,近期须要多练习一下. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 1000005; int _next[…