題目
對于下面這個圖可以知道當U涂中間三個時是不會對其它的三種產生限制的,而如果涂了4個則必然會占到L R其中一個相鄰的格子,涂了5個必然會占掉相鄰的L R兩個格子,這樣就產生了限制,我們只需把不滿足限制的情況為NO,其余為YES即可,我們來看滿足條件的情況,假如Un,Dn,得出L>=2 R>=2,因為必然會占掉L R兩個相鄰的格子,如果L或R為n,則L>=1 R>=1.假如U或D有一個=n-1,那么L R必然有一個格子會被占掉,得出L+R>=2*(U D等于n的個數)+1*(U D等于n-1的個數),對于U D 的判斷也類似,
Code:
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
int t;cin >> t;
while (t--)
{
int n, s, y, x, z;cin >> n >> s >> y >> x >> z;
int q = 0, f = 0, ans = 1;
if (y == n)q++;
if (z == n)q++;
if (y == n - 1)f++;
if (z == n - 1)f++;
if (s < q || x < q)ans = 0;
if (s + x < f+2*q)ans = 0;
q = 0, f = 0;
if (s == n)q++;
if (x == n)q++;
if (s == n - 1)f++;
if (x == n - 1)f++;
if (y < q || z < q)ans = 0;
if (y + z < f+2*q)ans = 0;
if (ans)cout << "YES" << endl;
else cout << "NO" << endl;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/266012.html
標籤:其他
上一篇:如何實作在直播中播放音頻檔案
