题意:

1、找一个字符串s使得 s不是给定母串的子串

2、且s要最短

3、s在最短情况下字典序最小

hash。,,结果t掉了。。。加了个姿势怪异的hash值剪枝才过。。

#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
#define N 1000100
#define ll long long
#define mod 2496764
char s[N];
short h[8][mod], tim;
bool f = false;
bool dfs(ll top, ll siz, ll dep) {
if (siz > 1000000) return false;
if(top == dep)
{
for(ll i = 0; i < 8; i++)
{
if(h[top][siz * 8 + i] != tim)
{
s[top] = i + 'A';
s[top+1] = 0;
f = true;
return true;
}
}
return false;
}
for(ll i = 0; i < 8; i++)
{
s[top] = i + 'A';
if(dfs(top+1, siz * 8 + i, dep))return true;
}
return false;
} int main(){
int i, j, T; scanf("%d",&T);
tim = 0; while(T--) {
tim ++;
scanf("%s", s);
f = false;
for(i = 0; s[i]; i++)
{
ll ans = 0;
for(j = 0; j < 7 && s[i+j]; j++)
{
ans = ans * 8 + s[i + j] - 'A';
h[j][ans] = tim;
}
} for(i = 0; i < 8; i++)
if(dfs(0, 0, i))break;
puts(s);
}
return 0;
}

HDU 4886 TIANKENG’s restaurant(Ⅱ) hash+dfs的更多相关文章

  1. HDU 4886 TIANKENG’s restaurant(Ⅱ) ( 暴力+hash )

    TIANKENG’s restaurant(Ⅱ) Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 130107/65536 K (Ja ...

  2. HDU 4883 TIANKENG’s restaurant Bestcoder 2-1(模拟)

    TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/O ...

  3. HDU 4883 TIANKENG’s restaurant

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4883 解题报告:一家餐馆一天中有n波客人来吃饭,第 i 波  k 客人到达的时间是 s ,离开时的时间 ...

  4. HDU 4883 TIANKENG’s restaurant (贪心)

    链接:pid=4883">带我学习.带我飞 第一次BC,稳挂,WA n多次.今天又一次做了一下 略挫 #include <iostream> #include <cs ...

  5. HDU 1010 Tempter of the Bone --- DFS

    HDU 1010 题目大意:给定你起点S,和终点D,X为墙不可走,问你是否能在 T 时刻恰好到达终点D. 参考: 奇偶剪枝 奇偶剪枝简单解释: 在一个只能往X.Y方向走的方格上,从起点到终点的最短步数 ...

  6. hdoj 4883 TIANKENG’s restaurant【贪心区间覆盖】

    TIANKENG’s restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/O ...

  7. hdu 4885 TIANKENG’s travel(bfs)

    题目链接:hdu 4885 TIANKENG's travel 题目大意:给定N,L,表示有N个加油站,每次加满油能够移动距离L,必须走直线,可是能够为斜线.然后给出sx,sy,ex,ey,以及N个加 ...

  8. HDOJ 4883 TIANKENG’s restaurant

    称号: TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Ja ...

  9. HDU 1078 FatMouse and Cheese ( DP, DFS)

    HDU 1078 FatMouse and Cheese ( DP, DFS) 题目大意 给定一个 n * n 的矩阵, 矩阵的每个格子里都有一个值. 每次水平或垂直可以走 [1, k] 步, 从 ( ...

随机推荐

  1. python_day5学习笔记

    一.正则表达式 字符: \d 匹配任何十进制数:相当于类[0-9] \D 匹配任何非数字字符:相当于类[^0-9] \s  匹配任何空白字符:相当于类[  \t\n\r\f\v] \S  匹配任何非空 ...

  2. linux命令(23):cp命令

    实例一:复制单个文件到目标目录 cp 1.log /home 说明: 1.在没有带-a参数时,两个文件的时间是不一样的.在带了-a参数时,两个文件的时间是一致的. 2.当目标文件已存在,会询问是否覆盖 ...

  3. Prometheus exporter的Node exporter是可以独立安装,用来测试的

    现在慢慢在把prometheus operator的一些概念组织完整. https://github.com/coreos/prometheus-operator/tree/master/contri ...

  4. AC日记——小魔女帕琪 洛谷 P3802

    小魔女帕琪 思路: 概率公式计算: 代码: #include <bits/stdc++.h> using namespace std; ],sig; int main() { ;i< ...

  5. AC日记——双栈排序 洛谷 P1155

    双栈排序 思路: 二分图染+模拟: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 #define ...

  6. 【转载】C++之继承与多态

    转自:http://www.cnblogs.com/kunhu/p/3631285.html 在程序设计领域,一个广泛认可的定义是“一种将不同的特殊行为和单个泛化记号相关联的能力”.和纯粹的面向对象程 ...

  7. JSON字符串转对象

    JSON(JavaScript Object Notation) JavaScript对象标记法:JSON是与JavaScript高度契合的:JSON 语法:    --数组(Array)用" ...

  8. php获取不到url问号之后的参数

    url规则已定义: RewriteRule ^/member/editprivilege/([0-9]+) /access.php?_u=mobile/editprivilege&aid=$1 ...

  9. KMS使用CLion作为IDE来调试

    KMS使用CLion作为IDE来调试,打开kms相应模块的目录,CLion自动识别相应的CMakeLists.txt. 然而会make失败,经搜索,看到Clion使用的自带的cmake,因此系统中安装 ...

  10. 转:攻击JavaWeb应用[5]-MVC安全

    转:http://static.hx99.net/static/drops/tips-347.html 攻击JavaWeb应用[5]-MVC安全 园长 · 2013/07/25 13:31 注:这一节 ...