一、竞赛题目
 Problem Statement 
 You are given a String[] grid representing a rectangular grid of letters. You are also given a String find, a word you are to find within the grid. 
The starting point may be anywhere in the grid. The path may move up, down, left, right, 
or diagonally from one letter to the next, and may use letters in the grid more than  once, 
but you may not stay on the same cell twice in a row (see example 6 for clarification).
You are to return an int indicating the number of ways find can be found within the grid.
If the result is more than 1,000,000,000, return -1.
  
 Definition
 Class:
 WordPath
 Method:
 countPaths
 Parameters:
 vector < string >, string
 Returns:
 int
 Method signature:
 int countPaths(vector < string> grid, string find)
 (be sure your method is public)
  
 Constraints
 -
 grid will contain between 1 and 50 elements, inclusive.
 -
 Each element of grid will contain between 1 and 50 uppercase (''A''-''Z'') letters, inclusive.
 -
 Each element of grid will contain the same number of characters.
 -
 find will contain between 1 and 50 uppercase (''A''-''Z'') letters, inclusive.
  
 Examples
 0)
 {"ABC",
 "FED",
 "GHI"}
 "ABCDEFGHI"
 Returns: 1
 There is only one way to trace this path. Each letter is used exactly once.
  
 1)
 {"ABC",
 "FED",
 "GAI"}
 "ABCDEA"
 Returns: 2
 Once we get to the ''E'', we can choose one of two directions for the final ''A''.
  
 2)
 {"ABC",
 "DEF",
 "GHI"}
 "ABCD"
 Returns: 0
 We can trace a path for "ABC", but there''s no way to complete a path to the letter ''D''.
  
 3)
 {"AA",
 "AA"}
 "AAAA"
 Returns: 108
 We can start from any of the four locations. From each location, we can then move in any of the three 
 possible directions for our second letter, and again for the third and fourth letter. 4 * 3 * 3 * 3 = 108.
  
 4)
 {"ABABA",
 "BABAB",
 "ABABA",
 "BABAB",
 "ABABA"}
 "ABABABBA"
 Returns: 56448
 There are a lot of ways to trace this path.
  
 5)
 {"AAAAA",
 "AAAAA",
 "AAAAA",
 "AAAAA",
 "AAAAA"}
 "AAAAAAAAAAA"
 Returns: -1
 There are well over 1,000,000,000 paths that can be traced.
  
 6)
 {"AB",
 "CD"}
 "AA"
 Returns: 0
 Since we can''t stay on the same cell, we can''t trace the path at all.
  
 This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or 
 reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. 
 (c)2003, TopCoder, Inc. All rights reserved.  

转载于:https://www.cnblogs.com/WuCountry/archive/2007/09/25/905184.html

[Quiz]竞赛题目 Word Trace相关推荐

  1. 计算机文本处理竞赛题目,文字处理竞赛题目(word2010).pdf

    文字处理竞赛题目(word2010).pdf (5页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 11.90 积分 文字录入与排版高手竞赛 大 学 计 算 ...

  2. NOI2019竞赛题目征集通知

    NOI2019竞赛题目征集通知 为扩大NOI竞赛的题目来源和范围,进一步提高NOI竞赛试题的质量和水平,CCF NOI科学委员会现面向国内外相关领域的指导教师和学生征集NOI2019的竞赛题目. 征题 ...

  3. 红书《题目与解读》第一章 数学 题解《ACM国际大学生程序设计竞赛题目与解读》

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 红书<题目与解读>第一章 数学 题解<ACM国际大学生程序设计竞赛题目与解读> ...

  4. Competition——AI:国内外人工智能比赛平台以及竞赛类型、竞赛题目、举行时间等之详细攻略(最全+ing)

    Competition--AI:国内外人工智能比赛平台以及竞赛类型.竞赛题目.举行时间等之详细攻略(最全+ing) tips (1).可以在各大比赛平台指定的讨论区,或者github网站上,找到历届选 ...

  5. 2020全国大学生数学建模竞赛【论文格式、时间节点及作品提交要求、竞赛题目下载、评分要点】【微信公众号:校苑数模】

    百度网盘下载:竞赛题目下载(官网下载,未经改动!)[提取码:zjxs] 2020年06月02日:2020全国大学生数学建模竞赛 2020年08月25日:全国大学生数学建模竞赛论文格式规范(2020年修 ...

  6. 2015美国数学建模a代码c语言,1985~2015美国大学生数学建模竞赛题目集锦.docx

    1985~2015美国大学生数学建模竞赛题目集锦 PAGE PAGE 42 1985~2015年美国大学生数学建模竞赛题目集锦目录 TOC \o "1-2" \h \z \u HY ...

  7. 数学建模债券投资组合_1998年全国大学生数学建模竞赛题目A题投资的收益和风险.PDF...

    1998年全国大学生数学建模竞赛题目A题投资的收益和风险 湖南大学数学建模网 1998 年全国大学生数学建模竞赛题目 A 题投资的收益和风险 市场上有n 种资产(如股票.债券.-)S ( i=1,-n ...

  8. 2010年高教社杯全国大学生数学建模竞赛题目B题解析及层次分析法AHP在其中的应用

    2010年高教社杯全国大学生数学建模竞赛题目 B题 2010年上海世博会影响力的定量评估 2010年上海世博会是首次在中国举办的世界博览会.从1851年伦敦的"万国工业博览会"开始 ...

  9. C语言的很吊的printf-----来自一个C语言竞赛题目

    一个C语言竞赛题目: 1 #include <stdio.h> 2 int main() 3 { 4 const int unix=1; 5 printf(&unix[" ...

最新文章

  1. SAP PI 适配器引擎
  2. SharePoint 2013中的视频体验增强(1)——把大象装进冰箱
  3. python面向对象编程的优点-Python面向对象编程 一
  4. 构造函数和析构函数中抛出异常
  5. linux 无线网卡连接网络连接不上去,【已解决】Ubuntu 10.04 无线网卡 无法连接
  6. 关于Log4j的初始化
  7. 1加6投屏_6月的早餐,1杯牛奶加燕麦,营养健康又美味,饱腹感很强
  8. Spring MVC Maven 环境搭建与部署
  9. 【Luogu 3389】【模板】高斯消元法(用高斯消元求解线性方程组)
  10. [翻译]XNA 3.0 Game Programming Recipes之forty-seven
  11. JSON与XML的综合比较
  12. xcode连接iphone调试_电脑操作手机?iPhone,安卓通吃?手机还能这么玩!
  13. 希尔加密法matlab,希尔密码加密解密
  14. doc 问卷调查模板表_Word制作电子版问卷调查模板表「教你方框内打钩」
  15. 一淘网发声明否认胁迫导航网站合作
  16. 开机后黑屏看不到桌面_开机不显示桌面黑屏怎么办_win10开机黑屏啥也没有的解决办法...
  17. 电脑需要装杀毒软件吗?两个理由看完你做决定
  18. 赛门铁克SSL证书chrome不支持解决方法
  19. 时间戳防止wms瓦片缓存
  20. php渔夫,渔夫有爱——5.2钓鱼新增内容 附日常稀有鱼经验

热门文章

  1. 2022-2028年中国煤及褐煤行业发展现状及未来前景分析报告
  2. 2022-2028年中国分离膜外壳行业市场调查研究及投资前景预测报告
  3. 2022-2028年中国纳滤膜产业发展态势及市场发展策略报告
  4. Go 学习笔记(59)— Go 第三方库之 etcd/clientv3 封装为方法使用(建立连接、设置key-value、获取key-value、获取带前缀的key-value)
  5. linux环境下快速配置hadoop集群免密登录
  6. 人要懂得放下已经发生,却又无法改变的事情
  7. 判别模型和生成模型的区别
  8. 机器学习数据不平衡不均衡处理之SMOTE算法实现
  9. 深度学习原理与框架-CNN在文本分类的应用 1.tf.nn.embedding_lookup(根据索引数据从数据中取出数据) 2.saver.restore(加载sess参数)...
  10. 拓展ARM研发进展与玩家