653B. Bear and Compressing
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相关推荐
- 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 ...
- D - Bear and Finding Criminals
Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long ro ...
- Bear and Finding Criminals (模拟)
Bear and Finding Criminals There are n cities in Bearland, num ...
- 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 ...
- 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 ...
- CodeForces 658C Bear and Forgotten Tree 3(构造)
题意:构造一棵树,有N个点,直径为d,深度为h 思路:首先构造一个长度为d的链,然后把其中一个距离边上为h的点变为根.然后我们就不停的在距离根为h上面的那一点不停的加点就好了,使得新加入的点的距离也为 ...
- Bear and Strings
The bear has a string s = s1s2- s|s| (record |s| is the string's length), consisting of lowercase En ...
- Bear and Finding Criminals
Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long ro ...
- Bear and Raspberry
Description The bear decided to store some raspberry for the winter. He cunningly found out the pric ...
最新文章
- 我被编程语言PUA了!
- 如何在FineUIMvc(ASP.NET MVC)视图中绑定多个模型?
- 用子函数的方法求一维数组中所有元素之和
- Selenium3自动化测试——3. 控制浏览器
- 计算机应用基础任务化教程知识点,计算机应用基础任务化教程教学大纲资料.doc...
- Linux 线程控制
- 数据结构开发(11):双向循环链表的实现
- linux boot 空间不足,解决Ubuntu 提示boot分区空间不足办法
- java proj4j 兰勃特投影设置地球半径 (+R )无效问题
- html字体样式圆体,网红字体“柚圆体”出现,书写工整又清新,老师也被这种字体圈粉...
- 幼儿园的计算机一年级的教案,我上一年级了幼儿园教案
- 饿了么商家开放平台踩坑记录1,php更新商品信息提示业务异常BUSINESS_ERROR by勤勤学长 318692996
- 2021-7-19-OpenStack基础知识学习
- Proximity sensor---Px318J
- 数值分析复习(一)线性插值、抛物线插值
- 逍遥游 一致性和哥德尔两大定理—— 读哥德尔之八
- Node.js中的child_process模块详解
- Ubantu18.04系统安装Hexagon SDK教程
- 计算机进位计数制实训课教案,计算机组成原理的教与学
- revit2016族管理:如何设置轮廓族来自动分类呢?
热门文章
- 华为荣耀9x怎么解账户锁_麒麟820,4000万像素,荣耀X10是下一部千元街机?
- Java 深copy 浅copy 引用copy
- no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
- android EditText光标位置,光标样式,EditText限制输入内容,软键盘遮挡的EditText,搜索框,限制输入表情
- 数据库实验三 SQL查询数据
- java解析json数组对象_JAVA中快速解析JSON对象里包含的JSON数组
- 【Makefile由浅入深完全学习记录4】变量和不同的赋值方式
- Nginx----高级
- 常用开发环境搭建配置教程(OneStall)
- 创建好centos7虚拟机之后连xshell连不上虚机