https://codeforces.com/contest/1494/problem/B
思路:关键就是四个点放还是不放,于是就每个点放还是不放枚举出一个状态,总共是2^2*4种状态。然后check其中有无合法状态。
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=110;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL b[20];
bool flag=1;
void check(LL ta,LL tb,LL tc,LL td,LL n){
if(ta<0||tb<0||tc<0||td<0) return;
if(ta>n-2||tb>n-2||tc>n-2||td>n-2) return;
flag=0;
}
int main(void)
{
cin.tie(0);std::ios::sync_with_stdio(false);
LL t;cin>>t;
while(t--){
LL n;cin>>n;
flag=1;
cin>>b[1]>>b[2]>>b[3]>>b[4];
for(LL i=0;i<=1;i++){
for(LL j=0;j<=1;j++){
for(LL k=0;k<=1;k++){
for(LL p=0;p<=1;p++){
LL ta=b[1];LL tb=b[2];LL tc=b[3];LL td=b[4];
if(i) ta--,td--;
if(j) ta--,tb--;
if(k) tb--,tc--;
if(p) tc--,td--;
check(ta,tb,tc,td,n);
}
}
}
}
if(1==flag) cout<<"NO"<<"\n";
else cout<<"YES"<<"\n";
}
return 0;
}