gym100825G. Tray Bien(輪廓線DP)

題意:3 * N的格子 有一些點是壞的 用1X1和1X2的磚鋪有多少種方法

題解:重新學了下輪廓線 寫的很舒服

?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;int n, m;
int vis[30][5];
ll dp[25][1 << 3];void dfs(int num, int i, int state, int nex)
{if(num == 3){dp[i + 1][nex] += dp[i][state];return;}if(vis[i][num + 1] || (state & (1 << num))) dfs(num + 1, i, state, nex);else{dfs(num + 1, i, state, nex); //填1x1if(!vis[i + 1][num + 1] && !(nex & (1 << num)))dfs(num + 1, i, state, nex | (1 << num));   //豎著填1X2if(num + 2 <= 3 && !vis[i][num + 2] && !(state & (1 << (num + 1))))dfs(num + 2, i, state, nex); // 橫著填1X2
    }
}int main()
{scanf("%d%d", &n, &m);for(int i = 1; i <= m; i++){double x, y;scanf("%lf%lf", &x, &y);vis[(int)x + 1][(int)y + 1] = 1;}dp[1][0] = 1LL;for(int i = 1; i <= n; i++)for(int st = 0; st < 8; st++)if(dp[i][st] > 0){bool f = true;for(int k = 0; k < 3; k++){if(st & (1 << k) && vis[i][k + 1]){f = false;break;}}if(!f) continue;dfs(0, i, st, 0);}printf("%lld\n", dp[n + 1][0]);return 0;
}
View Code

?

轉載于:https://www.cnblogs.com/lwqq3/p/9746461.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388307.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388307.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388307.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

github上打包的樣式為什么在預覽的時候,出現404

這是資源引用的問題 在這里主要是需要在dist的index.html文件內將"./static/css/style.css"改為"static/css/style.css",就可以加載成功了&#xff0c; 至于js的路徑"./static/js/app.js"&#xff0c;就不用改了轉載于:https://www.cnblogs.com/…

lambda函數,函數符_為什么您永遠不應該在Lambda函數中使用print()

lambda函數&#xff0c;函數符兩個Lambda用戶的故事 (A Tale of Two Lambda Users) 故事1&#xff1a;業余 (Tale #1: The Amateur) One moment everything is fine, then … Bam! Your Lambda function raises an exception, you get alerted and everything changes instantl…

[ BZOJ 4668 ] 冷戰

\(\\\) \(Description\) 有\(N\)個點&#xff0c;開始沒有邊相連&#xff0c;進行按順序給出的\(M\)個操作&#xff1a; \(0\ u\ v\) 將\(u,v\)兩點連一條邊\(1\ u\ v\) 查詢\(u,v\)兩點最早在第幾條邊連接的時候被連通每次詢問輸出一個邊的編號&#xff0c;強制在線。 \(N,M\i…

使用容器和數據庫克隆進行數據庫遷移

SQL Server遷移在DBA的生命周期中是一個常量&#xff0c;SQL Server 2008的支持終結正在推動大量的遷移規劃。數據庫遷移通常涉及將備份還原到目標環境&#xff0c;為應用程序測試提供開發和QA環境&#xff0c;以及識別已棄用的功能。當處理涉及需要數小時恢復的大量數據庫的大…

C++獲取PE文件的入口點

2009-10-07 10:17 C獲取PE文件的入口點 源碼&#xff1a; #include "stdafx.h" #include <iostream> #include <windows.h> using namespace std; int main(int argc, char* argv[]) { char *FileName argv[1]; HANDLE hFile CreateFile(FileName,GENE…

ai 中 統計_AI統計(第2部分)

ai 中 統計Today I plan to cover the following topics: Linear independence, special matrices, and matrix decomposition.今天&#xff0c;我計劃涵蓋以下主題&#xff1a;線性獨立性&#xff0c;特殊矩陣和矩陣分解。 線性獨立 (Linear independence) A set of vectors …

如何修改瀏覽器的默認滾動條樣式

如何修改瀏覽器的默認滾動條樣式 /* 瀏覽器滾動條樣式 *//* width */ ::-webkit-scrollbar {width: 4px;height: 4px; }/* Track */ ::-webkit-scrollbar-track {background: rgb(255, 255, 255);border-radius: 8px; }/* Handle */ ::-webkit-scrollbar-thumb {background: rg…

PE

PE文件規定了可執行文件的格式&#xff0c;凡是符合此格式的文件都能在windows系統上運行。PE文件的格式暫且不談&#xff0c;說一些感染PE文件的幾種途徑。 導入表感染。這個涉及比較復雜的操作&#xff0c;首先&#xff0c;要自行寫一個dll文件&#xff0c;提供程序中對原dl…

python入門系列:對象引用、垃圾回收、可變性

Python中的變量是什么 引言 Python和java中的變量本質不一樣&#xff0c;java的變量可以理解為一個盒子&#xff0c;用來容納我們的對象&#xff0c;使用前要先聲明它&#xff0c;好分配給我們合適的內存空間。Python的變量可以理解為一個標簽&#xff0c;先構造出對象&#xf…

twitter數據分析_Twitter上最受歡迎的數據科學文章主題

twitter數據分析If you’ve written data science articles or are trying to get started, finding the most popular topics is a big help in getting your articles read. Below are the steps to easily determine what these topics are using R and the results of the …

JAVA遇見HTML——JSP篇(JSP狀態管理)

案例&#xff1a;Cookie在登錄中的應用 URL編碼與解碼的工具類解決中文亂碼的問題&#xff0c;這個工具類在java.net.*包里 編碼&#xff1a;URLEncoder.encode(String s,String enc)//s&#xff1a;對哪個字符串進行編碼&#xff0c;enc&#xff1a;用的字符集&#xff08;例&…

PE文件講解

我們大家都知道&#xff0c;在Windows 9x、NT、2000下&#xff0c;所有的可執行文件都是基于Microsoft設計的一種新的文件格式Portable Executable File Format&#xff08;可移植的執行體&#xff09;&#xff0c;即PE格式。有一些時候&#xff0c;我們需要對這些可執行文件進…

easyui 布局之window和panel一起使用時,拉動window寬高時panel不跟隨一起變化

項目開發中布局是每一個組件都由最外層的window和內部的至少一個panel組成&#xff0c;其他的細小組件再依次放到panel中。 問題&#xff1a;當拉動外部的window時我們希望內部的panel的寬高也跟著變化&#xff0c;但是并沒有&#xff0c;尤其拉動其高度是更為明顯&#xff0c;…

是什么使波西米亞狂想曲成為杰作-數據科學視角

平均“命中率”是什么樣的 (What an Average ‘Hit’ looks like) Before we break the song down, let us have a brief analysis of what the greatest hits of all time had in common. I have picked 1500 songs ( charting hits ) right from the ’50s to the’10s, spre…

PE文件感染和內存駐留

這次&#xff0c;作者將和大家一起討論病毒的感染技術。另外&#xff0c;從本文開始&#xff0c;我們將陸續接觸到一些病毒的高級編碼技術。例如&#xff0c;內存駐留、EPO&#xff08;入口點模糊&#xff09;技術、加密技術、多態和變形等。通過這些高級技巧&#xff0c;你將進…

Python函數積累

評估函數eval() 去掉參數最外側引號并執行余下語句的函數 fun:將讓任何輸入的字符串轉換為python語句&#xff08;如"12132" -> 12132&#xff09;轉載于:https://www.cnblogs.com/LYluck/p/10376531.html

流行編程語言_編程語言的流行度排名

流行編程語言There has never been a unanimous agreement on what the most popular programming languages are, and probably never will be. Yet we believe that there is merit in trying to come up with ways to rank the popularity of programming languages. It hel…

Attributes.Add用途與用法

Attributes.Add("javascript事件","javascript語句");如&#xff1a;this.TextBox1.Attributes.add("onblue", "window.Label1.style.backgroundColor#000000;");this.TextBox1.Attributes.Add("onblur","this.style.d…

使用UIWebView加載網頁

1、使用UIWebView加載網頁 運行XCode 4.3&#xff0c;新建一個Single View Application&#xff0c;命名為WebViewDemo。 2、加載WebView 在ViewController.h添加WebView成員變量和在ViewController.m添加實現 [cpp] view plaincopyprint?#import <UIKit/UIKit.h> …