app怎么查网站备案,广州网站建设需要多少钱,wordpress首页静态页面,网站建设吉金手指专业11传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a;
给你个不规则的网络格子#xff0c;有nnn列#xff0c;每列有aia_iai个格子#xff0c;让你将121212的多米诺骨牌无重叠的放进去#xff0c;问最多能放多少个。
思路#xff1a;
首先如果点数小的话…传送门
文章目录题意思路题意
给你个不规则的网络格子有nnn列每列有aia_iai个格子让你将1×21×21×2的多米诺骨牌无重叠的放进去问最多能放多少个。
思路
首先如果点数小的话就是个网络流建模的板子但是显然这个题是不能建图的但是我们还是可以利用网络流的思想。 将格子进行黑白染色一个多米诺骨牌就包含了一个黑格子和一个白格子。比较显然的是如果黑白格子数量一样那么一定可以将其全部填上多米诺骨牌。否则我们将多余的骨牌都删掉就好啦答案就是min(ans1,ans2)min(ans1,ans2)min(ans1,ans2)。 染完色的图大概是这样亚子的我们计算黑白颜色的时候可以发现如果是偶数直接除222否则看这一列是奇数列还是偶数列奇数列黑色多一个偶数列白色多一个。 证明的话就是类似二分图的证明对与小的哪一个一定都可以与其周围一个格子进行匹配答案即为小的格子的个数。
// Problem: D. Domino for Young
// Contest: Codeforces - Codeforces Round #609 (Div. 2)
// URL: https://codeforces.com/contest/1269/problem/D
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].ltr[u].r1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n;
int a[N];int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);LL ans10,ans20;scanf(%d,n);for(int i1;in;i){int x; scanf(%d,x);ans1x/2; ans2x/2;if(x%21){if(i%21) ans1;else ans2;}}printf(%lld\n,min(ans1,ans2));return 0;
}
/**/