裸的穷举搜索。

研究了好久怎么输入$dict.txt$,$USACO$好像对$freopen$的顺序还有要求?

 /*
ID: Starry21
LANG: C++
TASK: namenum
*/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define N 4617
map<string,bool> vis;
char a[];
string s[];
int len;
bool f=;
void dfs(int i,string n)
{
if(i>len)
{
//cout<<n<<endl;
if(vis[n])
{
f=;
cout<<n<<endl;
}
return ;
}
int t=a[i]-'';
for(int k=;k<=;k++)
dfs(i+,n+s[t][k]);
}
int main()
{
freopen("namenum.in","r",stdin);
freopen("namenum.out","w",stdout);
s[]="ABC",s[]="DEF",s[]="GHI",s[]="JKL";
s[]="MNO",s[]="PRS",s[]="TUV",s[]="WXY";
scanf("%s",a+);
string t;
freopen("dict.txt","r",stdin);
for(int i=;i<=N;i++)
{
cin>>t;
vis[t]=;
}
len=strlen(a+);
//printf("%d\n",len);
dfs(,"");
if(f==) puts("NONE");
return ;
}

USACO 1.3 Name That Number【暴搜】的更多相关文章

  1. Usaco 2.3 Zero Sums(回溯DFS)--暴搜

    Zero SumConsider the sequence of digits from 1 through N (where N=9) in increasing order: 1 2 3 ... ...

  2. Codeforces Round #238 (Div. 2) D. Toy Sum 暴搜

    题目链接: 题目 D. Toy Sum time limit per test:1 second memory limit per test:256 megabytes 问题描述 Little Chr ...

  3. Sicily1317-Sudoku-位运算暴搜

    最终代码地址:https://github.com/laiy/Datastructure-Algorithm/blob/master/sicily/1317.c 这题博主刷了1天,不是为了做出来,AC ...

  4. codeforces 339C Xenia and Weights(dp或暴搜)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Weights Xenia has a set of weig ...

  5. HDU4403(暴搜)

    A very hard Aoshu problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

  6. [POJ 1204]Word Puzzles(Trie树暴搜&amp;AC自己主动机)

    Description Word puzzles are usually simple and very entertaining for all ages. They are so entertai ...

  7. HDU - 6185 Covering(暴搜+递推+矩阵快速幂)

    Covering Bob's school has a big playground, boys and girls always play games here after school. To p ...

  8. hdu 4400 离散化+二分+BFS(暴搜剪枝还超时的时候可以借鉴一下)

    Mines Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  9. 模拟 + 暴搜 --- Help Me with the Game

    Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3175   Accepted: ...

  10. 【BZOJ-3033】太鼓达人 欧拉图 + 暴搜

    3033: 太鼓达人 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 204  Solved: 154[Submit][Status][Discuss] ...

随机推荐

  1. Luogu P2602 [ZJOI2010]数字计数 数位DP

    很久以前就...但是一直咕咕咕 思路:数位$DP$ 提交:1次 题解:见代码 #include<cstdio> #include<iostream> #include<c ...

  2. PHP mysqli_num_fields() 函数

    mysqli_num_fields() 函数返回结果集中字段(列)的数量. 语法 mysqli_num_fields(result); 参数 描述 result 必需.规定由 mysqli_query ...

  3. Vue 事件监听实现导航栏吸顶效果(页面滚动后定位)

    Vue 事件监听实现导航栏吸顶效果(页面滚动后定位) Howie126313 关注 2017.11.19 15:05* 字数 100 阅读 3154评论 0喜欢 0 所说的吸顶效果就是在页面没有滑动之 ...

  4. spring-boot web项目常用配置

    一.对用户输入query参数过滤空字符串 使用 WebBindingInitializer 来对string类型参数进行过滤,但是这种方式只能处理query参数不能处理body参数 代码例子: /** ...

  5. luogu 1220 关路灯 区间dp

    Code: #include <bits/stdc++.h> #define ll long long #define N 1003 #define setIO(s) freopen(s& ...

  6. javascript JSON.parse and JSON.stringify

    var jstu = '{"name": "xiaoqiang", "age": 18}'; console.log(jstu); var ...

  7. Linux的简单命令(防火墙篇)

    名称 解释 重启 reboot 关机 shutdown  -h   now poweroff 查看本机IP地址 ifconfig 查看默认网卡信息的文件 cat /etc/sysconfig/netw ...

  8. Leetcode题目200.岛屿数量(BFS+DFS+并查集-中等)

    题目描述: 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量.一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的.你可以假设网格的四个边均被水包围. 示例 ...

  9. 2018-2019-2 20165330《网络对抗技术》Exp8 Web基础

    目录 基础问题 相关知识 实验内容 实验步骤 实验总结与体会 实验内容 Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML ...

  10. linux中wget未找到命令

    (转)linux中wget未找到命令   转:https://blog.csdn.net/djj_alice/article/details/80407769 在装数据库的时候发现无法使用wget命令 ...