B. Bear and Compressing:题目

纯纯暴力DFS,和dp有啥关系!不想写了,copy一份,写的真精简。
#include <bits/stdc++.h>
using namespace std;
int n, m;
string a[40], b[40];
int f[10][10][2];int dfs(int pos, int pre, int flag) {if (!pos)return flag;if (f[pos][pre][flag] != -1)return f[pos][pre][flag];int res = 0;for (int i = 0; i < m; ++i) {res += dfs(pos - 1, a[i][0] - 'a', flag && (b[i][0] - 'a' == pre));}f[pos][pre][flag] = res;return res;
}
int main() {cin >> n >> m;for (int i = 0; i < m; ++i)cin >> a[i] >> b[i];memset(f, -1, sizeof f);cout << dfs(n - 1, 0, 1) << endl;return 0;
}
明天开始1400分内容了,冲

653B. Bear and Compressing相关推荐

  1. Code Forces Bear and Forgotten Tree 3 639B

    B. Bear and Forgotten Tree 3 time limit per test2 seconds memory limit per test256 megabytes inputst ...

  2. D - Bear and Finding Criminals

    Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long ro ...

  3. Bear and Finding Criminals (模拟)

                                          Bear and Finding Criminals There are n cities in Bearland, num ...

  4. IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) A. Bear and Three Balls 水题

    A. Bear and Three Balls 题目连接: http://www.codeforces.com/contest/653/problem/A Description Limak is a ...

  5. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题

    A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes ...

  6. CodeForces 658C Bear and Forgotten Tree 3(构造)

    题意:构造一棵树,有N个点,直径为d,深度为h 思路:首先构造一个长度为d的链,然后把其中一个距离边上为h的点变为根.然后我们就不停的在距离根为h上面的那一点不停的加点就好了,使得新加入的点的距离也为 ...

  7. Bear and Strings

    The bear has a string s = s1s2- s|s| (record |s| is the string's length), consisting of lowercase En ...

  8. Bear and Finding Criminals

    Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long ro ...

  9. Bear and Raspberry

    Description The bear decided to store some raspberry for the winter. He cunningly found out the pric ...

最新文章

  1. 我被编程语言PUA了!
  2. 如何在FineUIMvc(ASP.NET MVC)视图中绑定多个模型?
  3. 用子函数的方法求一维数组中所有元素之和
  4. Selenium3自动化测试——3. 控制浏览器
  5. 计算机应用基础任务化教程知识点,计算机应用基础任务化教程教学大纲资料.doc...
  6. Linux 线程控制
  7. 数据结构开发(11):双向循环链表的实现
  8. linux boot 空间不足,解决Ubuntu 提示boot分区空间不足办法
  9. java proj4j 兰勃特投影设置地球半径 (+R )无效问题
  10. html字体样式圆体,网红字体“柚圆体”出现,书写工整又清新,老师也被这种字体圈粉...
  11. 幼儿园的计算机一年级的教案,我上一年级了幼儿园教案
  12. 饿了么商家开放平台踩坑记录1,php更新商品信息提示业务异常BUSINESS_ERROR by勤勤学长 318692996
  13. 2021-7-19-OpenStack基础知识学习
  14. Proximity sensor---Px318J
  15. 数值分析复习(一)线性插值、抛物线插值
  16. 逍遥游 一致性和哥德尔两大定理—— 读哥德尔之八
  17. Node.js中的child_process模块详解
  18. Ubantu18.04系统安装Hexagon SDK教程
  19. 计算机进位计数制实训课教案,计算机组成原理的教与学
  20. revit2016族管理:如何设置轮廓族来自动分类呢?

热门文章

  1. 华为荣耀9x怎么解账户锁_麒麟820,4000万像素,荣耀X10是下一部千元街机?
  2. Java 深copy 浅copy 引用copy
  3. no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
  4. android EditText光标位置,光标样式,EditText限制输入内容,软键盘遮挡的EditText,搜索框,限制输入表情
  5. 数据库实验三 SQL查询数据
  6. java解析json数组对象_JAVA中快速解析JSON对象里包含的JSON数组
  7. 【Makefile由浅入深完全学习记录4】变量和不同的赋值方式
  8. Nginx----高级
  9. 常用开发环境搭建配置教程(OneStall)
  10. 创建好centos7虚拟机之后连xshell连不上虚机