omaosmds

asdasd
mail@pastecode.io avatar
unknown
csharp
3 years ago
2.5 kB
2
Indexable
Never
    class Program
    {
        static bool Check(int n, int U, int R, int D, int L, bool a, bool b, bool c, bool d)
        {
            int nl = n;
            int nu = n;
            int nr = n;
            int nd = n;
            int minu = 0;
            int minr = 0;
            int mind = 0;
            int minl = 0;
            int UU = U;
            int DD = D;
            int RR = R;
            int LL = L;
 
            if (!a) {
                nl--;
                nu--;
            }
 
            if (a)
            {
                minl ++;
                minu ++;
            }
 
            if (!b) {
                nu--;
                nr--;
            }
 
            if (b)
            {
                minu++;
                minr++;
            }
 
            if (!c)
            {
                nd--;
                nr--;
            }
 
            if (c)
            {
                minr++;
                mind++;
            }
 
            if (d)
            {
                minl++;
                mind++;
            }
 
            if (!d)
            {
                nd--;
                nl--;
            }
 
            if (nl < L || nu < U || nr < R || nd < D || nl < 0 || nu < 0 || nd < 0 || nr < 0 || L < 0 || U < 0 || R < 0 || D < 0 || mind > DD || minu > UU || minr > RR || minl > LL)
            {
                return false;
            }
 
            return true;
        }
 
        static void Main(string[] args)
        {
            var t = long.Parse(Console.ReadLine());
 
            for (long ii = 0; ii < t; ii++)
            {
                var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int n = p[0];
                int U = p[1];
                int R = p[2];
                int D = p[3];
                int L = p[4];
 
 
                bool tmp = false;
                for (int i1 = 0; i1 <= 1; i1++)
                    for (int i2 = 0; i2 <= 1; i2++)
                        for (int i3 = 0; i3 <= 1; i3++)
                            for (int i4 = 0; i4 <= 1; i4++)
                                if (Check(n, U, R, D, L, i1 == 0, i2 == 0, i3 == 0, i4 == 0))
                                {
                                    tmp = true;
                                }
 
                if (tmp)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }