裸的穷举搜索。

研究了好久怎么输入$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. Neo4j入门博客分享

    Neo4j学习参考博客:https://www.cnblogs.com/ljhdo/p/5516793.html Neo4j Cypher查询语言详解 http://www.ttlsa.com/nos ...

  2. remmina连接xfce桌面的centos7

    vnc无法连到linux server,但ssh可以的解决方法 原文引自:https://blog.csdn.net/h00ahaha/article/details/84440449   今天用vn ...

  3. SpringMVC 请求调用过程

    1.spring mvc请所有的请求都提交给DispatcherServlet,它会委托应用系统的其他模块负责负责对请求进行真正的处理工作. 2.DispatcherServlet查询一个或多个Han ...

  4. hdfs基本使用

    基本命令 /usr/local/hadoop/bin/hadoop fs -ls / /usr/local/hadoop/bin/hadoop fs -mkdir /test # 创建目录 /usr/ ...

  5. sqlite3-python

    官网资料 https://sqlite.org/lang_createtable.html 操作参考: https://www.runoob.com/sqlite/sqlite-insert.html ...

  6. codeforces#1108E2. Array and Segments (线段树+扫描线)

    题目链接: http://codeforces.com/contest/1108/problem/E2 题意: 给出$n$个数和$m$个操作 每个操作是下标为$l$到$r$的数减一 选出某些操作,使$ ...

  7. Java中可变参数

    从java5开始出现了可变参数,这是对java方法及数组的拓展! 方法中可以接受的参数不再是固定个数的,而是随着具体需求传递的多少来决定. 定义格式: 返回值类型  方法名(参数类型 ... 形式参数 ...

  8. 怎样用linux命令知道系统是ubuntu还是redhat或者其它的系统?

    1.第一种方法:# lsb_release -aLSB Version:    :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4. ...

  9. Java中的<< 和 >> 和 >>> 分析理解

    Java中的<< 和 >> 和 >>> 详细分析 <<表示左移移,不分正负数,低位补0: 注:以下数据类型默认为byte-8位 左移时不管正负,低 ...

  10. 单调队列优化dp,k次移动求最长路

    洛谷2254 给你k次移动 每次移动给你一个时间段 a,b和方向dir 地图上有障碍物 为了不撞上障碍物你可以施法让箱子停下来 问箱子可以走的最长路 ((以下是洛谷的题解)) /*首先考虑对于时间t来 ...