A. Boboniu Likes to Color Balls(思维)

A . . . . . . A题都想了一下......

绿 > 红绿蓝->白最多只会只执行一次

为啥?

, 构成回文,只和最终某种颜色是奇是偶有关

偶数就对称放置

, 奇数就对称放,多余的一个放中间

绿 > 绿 执行红绿蓝->白两次不会改变红绿蓝的奇偶性

对当前局面没有改变

所以最多执行一次就好了

#include <bits/stdc++.h>
using namespace std;
#define int long long
int r,g,b,w,t;
bool isok( )
{
	int ji=0;
	if( r%2==1 )	ji++;
	if( g%2==1 )	ji++;
	if( b%2==1 )	ji++;
	if( ji==0 )	return true;
	if( ji==1&&w%2==0 )	return true;//1个奇数情况才可以把奇数放中间 
	return false;
}
signed main()
{
	cin >> t;
	while( t-- )
	{
		cin >> r >> g >> b >> w;
		if( isok() )	cout << "YES\n";
		else if(r&&g&&b )
		{
			r--,g--,b--,w+=3;
			if( isok() )	cout << "YES\n";
			else	cout << "NO\n";
		}
		else	cout << "NO\n";
	}
}

猜你喜欢

转载自blog.csdn.net/jziwjxjd/article/details/107971102