N = int(input()) A, B = [int(x) for x in input().split()] D = [int(x) for x in input().split()] PARITY = [0]*N for i in range(1,N): PARITY[i] = (PARITY[i-1] + D[i-1])%2 if PARITY[N-1] != (A+B)%2: print("NO") exit() X = [0]*N Y = [0]*N X[N-1] = A Y[N-1] = B def rect_intersect(pr, nr, my_p): wlo1, whi1, zlo1, zhi1 = pr wlo2, whi2, zlo2, zhi2 = nr for wb in [wlo1, whi1, wlo2, whi2]: for w in [wb-1, wb, wb+1]: for zb in [zlo1, zhi1, zlo2, zhi2]: for z in [zb-1,zb,zb+1]: if max(zlo1,zlo2)<=z<=min(zhi1,zhi2) and max(wlo1,wlo2)<=w<=min(whi1,whi2) and w%2 == my_p and z%2 == my_p: return w,z return None def put(px, py, pmin, pmax, nx, ny, nmin, nmax, my_p): pw = px-py pz = px+py nw = nx-ny nz = nx+ny prect = ( (pw-pmax, pw-pmin, pz-pmax, pz+pmax), (pw+pmin, pw+pmax, pz-pmax, pz+pmax), (pw-pmax, pw+pmax, pz-pmax, pz-pmin), (pw-pmax, pw+pmax, pz+pmin, pz+pmax), ) nrect = ( (nw-nmax, nw-nmin, nz-nmax, nz+nmax), (nw+nmin, nw+nmax, nz-nmax, nz+nmax), (nw-nmax, nw+nmax, nz-nmax, nz-nmin), (nw-nmax, nw+nmax, nz+nmin, nz+nmax), ) #print(f"PUTTING WITH {nw=} {nmin=} {nmax=} {pw=} {pmin=} {pmax=} {my_p=}") #print(f"PUTTING WITH {nz=} {nmin=} {nmax=} {pz=} {pmin=} {pmax=} {my_p=}") for pr in prect: for nr in nrect: wz = rect_intersect(pr, nr, my_p) if wz != None: #print(f"GOT {wz=}") w,z = wz assert((w+z)%2 == 0) x = (w+z)//2 y = (z-w)//2 return x,y print("NO") exit() def place(i, j): if i+1 == j: return mid = (i+j)//2 pmax = sum(D[i:mid]) nmax = sum(D[mid:j]) pmin = max(2*max(D[i:mid])-pmax, 0) nmin = max(2*max(D[mid:j])-nmax, 0) #print(f"PLACING {mid=}") X[mid], Y[mid] = put(X[i], Y[i], pmin, pmax, X[j], Y[j], nmin, nmax, PARITY[mid]) #print(f"AT {X[mid]=} {Y[mid]=}") place(i, mid) place(mid, j) place(0, N-1) for i in range(N-1): dx = X[i]-X[i+1] dy = Y[i]-Y[i+1] assert(abs(dx)+abs(dy) == D[i]) print("YES") for i in range(N): print(X[i], Y[i]) """ team36@FEP-PC16328:~/Desktop/loke$ python3 h.py 4 10 6 7 8 5 PLACING mid=1 PUTTING WITH nw=4 nmin=3 nmax=13 pw=0 pmin=7 pmax=7 my_p=1 GOT w=7 PUTTING WITH nz=16 nmin=3 nmax=13 pz=0 pmin=7 pmax=7 my_p=1 NO """