其他分享
首页 > 其他分享> > Codeforces Round #734 (Div. 3)

Codeforces Round #734 (Div. 3)

作者:互联网

比赛链接

Codeforces Round #734 (Div. 3)

D1. Domino (easy version)

给你 \(t\) 组数据。对于每组数据给你一个 \(n \times m\) 的网格(\(n\) 为网格高度, \(m\) 为网格宽度,且网格的数量为偶数),要求在网格中放置多米诺骨牌,每个骨牌占据 \(1 \times 2\) 的网格区域。对于这 \(\frac{n m}{2}\) 个骨牌,要求正好有 \(k\) 个横着放置,而剩下的 \(\frac{n m}{2}-k\) 个竖着放置,正好铺满台面。现在要你给出对于每组 \(n, m\) 和 \(k\) ,是否有一种方案满足条件。如果有,输出 YES,反之输出 NO

解题思路

构造

分情况讨论:

代码

// Problem: D1. Domino (easy version)
// Contest: Codeforces - Codeforces Round #734 (Div. 3)
// URL: https://codeforces.com/contest/1551/problem/D1
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// %%%Skyqwq
#include <bits/stdc++.h>
 
//#define int long long
#define help {cin.tie(NULL); cout.tie(NULL);}
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
 
template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }
 
template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}


int main()
{
    int t,n,m,k;
    for(cin>>t;t;t--)
    {
    	cin>>n>>m>>k;
    	if(n%2==0&&m%2==0)
    		puts(k%2?"NO":"YES");
    	else if(n&1)
    		puts(k<m/2||(k-m/2)%2?"NO":"YES");
    	else
    	{
			k=n*m/2-k;
			puts(k<n/2||(k-n/2)%2?"NO":"YES");		
    	}
    }
    return 0;
}

标签:填满,网格,Codeforces,偶数,734,骨牌,Div,define
来源: https://www.cnblogs.com/zyyun/p/16287010.html