## 思路

1. $\forall p \in (l,r], r[p][0]\leq a[l] \leq r[p][1]$
2. $\forall p \in (l,r], l[p][0] \leq a[p] \leq l[p][1]$

$1$的情况同理。

//HomuraCat codes it!
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<bitset>
#include<queue>
#include<vector>
#include<set>
#include<cstdlib>
#include<iostream>
#include<utility>
#include<map>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define eps 1e-4
#define mod 1000000007
#define lowbit(x) (x & -x)
#define N 100005
#define clr(arr) memset(arr, 0, sizeof arr)
#define bset std::bitset<N>
#define pi std::pair<int, int>
inline ll read ()
{
ll x = 0; bool flag = 0; char ch = getchar();
while (!isdigit(ch) && ch != '-') ch = getchar();
if (ch == '-') flag = 1, ch = getchar();
while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
if (flag) x = -x; return x;
}
inline ll qabs (ll x) { return x < 0 ? -x : x; }
inline ll qpow (ll x, int y)
{
ll ret = 1;
while (y)
{
if (y & 1) ret = ret * x % mod;
x = x * x % mod;
y >>= 1;
}
return ret;
}
int n, m, a[N], l[N][2], r[N][2], f[N][2], ans[N];
bool flag = 0;
std::set<pi> s[2];
int main ()
{
fo (i, 1, n)
{
}
if (l[1][0] <= a[1] && a[1] <= l[1][1] && r[1][0] == 0)
s[0].insert(mp(0, 0));
if (r[1][0] <= a[1] && a[1] <= r[1][1] && l[1][0] == 0)
s[1].insert(mp(0, 0));

fo (i, 2, n)
{
bool flag[2] = {0, 0};
flag[0] = s[0].size() ? 1 : 0; flag[1] = s[1].size() ? 1 : 0;
if (flag[1])
s[0].insert(mp(a[i - 1], i - 1));
if (flag[0])
s[1].insert(mp(a[i - 1], i - 1));

if (a[i] > l[i][1] || a[i] < l[i][0])
s[0].clear();
if (a[i] > r[i][1] || a[i] < r[i][0])
s[1].clear();

s[0].erase(s[0].begin(), s[0].lower_bound(mp(r[i][0], -1)));
s[0].erase(s[0].upper_bound(mp(r[i][1], n + 1)), s[0].end());
s[1].erase(s[1].begin(), s[1].lower_bound(mp(l[i][0], -1)));
s[1].erase(s[1].upper_bound(mp(l[i][1], n + 1)), s[1].end());

if (!(s[0].size() || s[1].size())) break;
if (s[0].size())
f[i][0] = (*s[0].begin()).S;
else
f[i][0] = -1;
if (s[1].size())
f[i][1] = (*s[1].begin()).S;
else
f[i][1] = -1;
}
if (s[0].size() || s[1].size())
{
printf("Yes\n");
int pos = n;
bool now = f[pos][1] >= 0;
while (pos)
{
int lst = pos;
if (f[pos][now] >= 0)
{
pos = f[pos][now];
fo (i, pos + 1, lst)
ans[i] = now;
now ^= 1;
}
}
fo (i, 1, n) printf("%d ", ans[i]);
}
else
printf("No\n");
return 0;
}


/jk

/wq

QwQ！