653B. Bear and Compressing
生活随笔
收集整理的這篇文章主要介紹了
653B. Bear and Compressing
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
B. Bear and Compressing:題目
純純暴力DFS,和dp有啥關(guān)系!不想寫了,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分內(nèi)容了,沖 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的653B. Bear and Compressing的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html5 --- IDBDataba
- 下一篇: 若依框架入门