USACO 1.3 Name That Number【暴搜】
裸的穷举搜索。
研究了好久怎么输入$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【暴搜】的更多相关文章
- 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 ... ...
- 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 ...
- Sicily1317-Sudoku-位运算暴搜
最终代码地址:https://github.com/laiy/Datastructure-Algorithm/blob/master/sicily/1317.c 这题博主刷了1天,不是为了做出来,AC ...
- codeforces 339C Xenia and Weights(dp或暴搜)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Xenia and Weights Xenia has a set of weig ...
- HDU4403(暴搜)
A very hard Aoshu problem Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- [POJ 1204]Word Puzzles(Trie树暴搜&AC自己主动机)
Description Word puzzles are usually simple and very entertaining for all ages. They are so entertai ...
- HDU - 6185 Covering(暴搜+递推+矩阵快速幂)
Covering Bob's school has a big playground, boys and girls always play games here after school. To p ...
- hdu 4400 离散化+二分+BFS(暴搜剪枝还超时的时候可以借鉴一下)
Mines Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- 模拟 + 暴搜 --- Help Me with the Game
Help Me with the Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3175 Accepted: ...
- 【BZOJ-3033】太鼓达人 欧拉图 + 暴搜
3033: 太鼓达人 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 204 Solved: 154[Submit][Status][Discuss] ...
随机推荐
- Idea使用Lombok简化实体类代码
引入相应的maven包 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lo ...
- vim 自动代码格式调整
1,gg 跳转到第一行 2,shift+v 转到可视模式 3,shift+g 全选 4,按下神奇的 =
- 利用Python构建时间序列模型解决实际问题的正确姿势
要本着应用到实际工作中目的去学时间序列分析,才能深入浅出的学会,不要纠结于理论,只听我的,我有信心说明白. 本章内容 趋势分析 序列分解 序列预测 序列分解 统计学基础铺垫 划分 时间序列按照季节性划 ...
- jenkins+Maven从SVN上构建项目
一.安装Maven 下载地址:https://maven.apache.org/download.cgi 把下载的安装包解压 tar -xvf apache-maven--bin.tar.gz 配置环 ...
- mybatis 操作其他数据库的数据表
配置文件里面配置的数据库只是默认数据库,并不是只能操作默认数据库.(被自己蠢死了,唉) 1. 注解方式 使用BaseMapper方式操作数据表时,在表对应的实体类上的 @table 注解描述表名时加上 ...
- Linux设备驱动程序 之 open和release
open方法 open方法提供给驱动程序以初始化的能力,在大部分驱动程序汇总,open应该完成以下工作: 1. 检查特定设备的错误,如设备为准备就绪或者硬件问题: 2. 如果设备是首次打开,则对其进行 ...
- Python中调用shell
1 简单调用shell命令 os.system(command) 在一个子shell中运行command命令, 并返回command命令执行完毕后的退出状态. 这实际上是使用C标准库函数system( ...
- 使用UltraISO制作linux系统安装u盘启动盘
1.首先打开UltraISO软件,尽量下载最新版的,小编曾用某个旧版的UltraISO,制作的安装盘,不能不能识别磁盘,安装失败! 2.点击工具栏中的第二个打开镜像文件工具,如图红色方框标志按钮,然后 ...
- 【Mybatis】向MySql数据库插入千万记录 单条插入方式,用时 1h16m30s
本例代码下载:https://files.cnblogs.com/files/xiandedanteng/InsertMillionComparison20191012.rar 相对于批量插入,这种方 ...
- hibernate中session的管理方式
package loaderman.c_session; import loaderman.b_second_cache.Dept; import loaderman.b_second_cache.E ...