摘要: 题意:n个基地放在2维平面,然后m个炸弹人,每个炸弹人可以炸一行或者一列,输出每个炸弹人炸掉的基地个数。思路:用map >对应起来一行或者一列。(用set没过,估计数据里有多个基地位于同一个点上)#include#include#include#includeusing namespace std;... 阅读全文
posted @ 2015-08-22 21:12 gongpixin 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题意:产生第m大的排列思路:使用 next_permutation函数(头文件algorithm)#include#include#includeusing namespace std;int main(){ int a[1024],n,m,i; while(~scanf("%d%d",... 阅读全文
posted @ 2015-08-22 20:07 gongpixin 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题意:求目标串中出现了几个模式串思路:ac自动机#include#include#include#includeusing namespace std;struct Trie{ int next[500010][26],fail[500010],end[500010]; int root... 阅读全文
posted @ 2015-08-22 16:40 gongpixin 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 题意:在一个串中找 EAEBE 的形式的最长的E,其中E为一个字符串,也就是说找到前缀与后缀相同,并且串中还存在相同的一段,它们不能重复。思路:利用next数组,next[len]代表的即是最大的相同的前缀与后缀,然后让 i 从len-1往前遍历找到 i>=2(前面部分最少要有2个字符),在过程中更... 阅读全文
posted @ 2015-08-22 15:39 gongpixin 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题意:求最小的循环矩形思路:分别求出行、列的最小循环节,乘积即可。#include#include#includeusing namespace std;int next[10005];int r,c;char str[10005][80];bool equalR(int i,int j){//行相... 阅读全文
posted @ 2015-08-22 13:34 gongpixin 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题意:两个字符串s、t,求s和t的最长的相同的前缀和后缀思路:先求s的next数组,再求t的next数组(即代码中ex数组,此时不是自己与自己匹配,而是与s匹配),最后看ex[len2]即可(len2为串t的长度)。#include#include#includeusing namespace st... 阅读全文
posted @ 2015-08-22 11:07 gongpixin 阅读(174) 评论(0) 推荐(0) 编辑