#include /* #include #include namespace mp = boost::multiprecision; using bint = mp::cpp_int; */ #include #include #include #include #include #include #include #include #include #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) using namespace std; using namespace atcoder; using namespace internal; //alias g++='g++ -I/mnt/c/Users/Owner/Desktop/ac-library' using ll = long long; using ld = long double; using P = pair; using PI = pair,int>; using PL = pair; using PLL = pair, long long>; using Pxy = pair; const int INF = 1001001007; const int modd = 1000000007; const long long modl = 1000000007LL; const long long mod = 998244353LL; const ll inf = 2e18; template void priv(vector &ar){ rep(i,ar.size()-1) cout << ar[i] << " "; cout << ar[ar.size()-1] << endl; } template void privv(vector> &ar){ rep(i,ar.size()){ rep(j,ar[i].size()-1) cout << ar[i][j] << " "; cout << ar[i][ar[i].size()-1] << endl; } } template bool range(SC a, SC b, SC x){return (a <= x && x < b);} bool rrange(P a, P b, P xy){ bool s = range(a.first,b.first,xy.first); bool t = range(a.second,b.second,xy.second); return (s && t); } template void sor(vector &ar){sort(ar.begin(),ar.end());} template void rev(vector &ar){reverse(ar.begin(),ar.end());} template bool chmin(SF &a, const SF &b){if(a>b){a = b; return true;} return false;} template bool chmax(SG &a, const SG &b){if(a void eru(vector &ar){sor(ar);ar.erase(unique(ar.begin(),ar.end()),ar.end());} template SI last(vector &ar){return ar[ar.size()-1];} template SJ cel(SJ a, SJ b){if (a % b == 0) return a/b; return a/b +1;} template void pout(pair p) {cout << p.first << " " << p.second << endl;} void yes(){cout << "Yes" << endl;} void no (){cout << "No" << endl;} void yn (bool t){if(t)yes();else no();} void Yes(){cout << "YES" << endl;} void No (){cout << "NO" << endl;} void YN (bool t){if(t)Yes();else No();} void dout() {cout << setprecision(20);} vector dx = {0,1,0,-1}; vector dy = {1,0,-1,0}; const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string alp = "abcdefghijklmnopqrstuvwxyz"; ll gcds(ll a, ll b){ ll c = a % b; while (c != 0){ a = b; b = c; c = a % b; } return b; } void inc(vector

&a, int n){ int m = a.size(); rep(i,m){ a[i].first = max(1,a[i].first - 1); a[i].second = min(n,a[i].second + 1); } } //a C b bool crossin(P a, P b){ return (b.first <= a.first && a.second <= b.second); } P crossand(P a, P b){ if (a.first <= b.second && b.first <= a.second){ return P(max(a.first,b.first),min(a.second,b.second)); } else return P(-1,-1); } vector

uni(int n, vector

a, int x, int y){ if (a.size() == 0) return a; inc(a,n); vector ap; rep(i,a.size()){ ap.emplace_back(a[i].first); ap.emplace_back(a[i].second); } eru(ap); vector

ans; int nowle = ap[0]; int nowri = ap[0]; int w = ap.size(); rep(i,w-1){ int ile = ap[i]; int iri = ap[i+1]; bool t = false; rep(j,a.size()) if (crossin(P(ile,iri),a[j])) t = true; if (t) nowri = iri; else { ans.emplace_back(P(nowle,nowri)); nowle = iri; nowri = iri; } } if (nowri - nowle > 0) ans.emplace_back(P(nowle,nowri)); int m = ans.size(); vector

rec; if (x == y){ rep(i,m){ if (ans[i].first == x || ans[i].second == x){ if (ans[i].first == x) ans[i].first = x+1; else if (ans[i].second == x) ans[i].second = x-1; rec.emplace_back(ans[i]); } else if (ans[i].first <= x && x <= ans[i].second) { rec.emplace_back(P(ans[i].first,x-1)); rec.emplace_back(P(x+1,ans[i].second)); } else rec.emplace_back(ans[i]); } } else if (x + 1 == y){ rep(i,m){ if (ans[i].first == x && ans[i].second == y) continue; if (ans[i].first <= x && y <= ans[i].second){ if (ans[i].first == x || ans[i].second == y){ if (ans[i].first == x) ans[i].first = y+1; else if (ans[i].second == y) ans[i].second = x-1; rec.emplace_back(ans[i]); } else { rec.emplace_back(P(ans[i].first,x-1)); rec.emplace_back(P(y+1,ans[i].second)); } } else if (ans[i].first == y){ rec.emplace_back(P(y+1,ans[i].second)); } else if (ans[i].second == x){ rec.emplace_back(P(ans[i].first,x-1)); } else rec.emplace_back(ans[i]); } } else { rep(i,m){ if (ans[i].first <= x && y <= ans[i].second){ if (ans[i].first == x && ans[i].second == y){ rec.emplace_back(P(x+1,y-1)); } else if (ans[i].first == x || ans[i].second == y){ if (ans[i].first == x){ rec.emplace_back(P(x+1,y-1)); rec.emplace_back(P(y+1,ans[i].second)); } else if (ans[i].second == y){ rec.emplace_back(P(ans[i].first,x-1)); rec.emplace_back(P(x+1,y-1)); } } else { rec.emplace_back(P(ans[i].first,x-1)); rec.emplace_back(P(x+1,y-1)); rec.emplace_back(P(y+1,ans[i].second)); } } else if (ans[i].first <= x && x <= ans[i].second){ if (ans[i].first == x){ rec.emplace_back(P(x+1,ans[i].second)); } else if (ans[i].second == x){ rec.emplace_back(P(ans[i].first,x-1)); } else { rec.emplace_back(P(ans[i].first,x-1)); rec.emplace_back(P(x+1,ans[i].second)); } } else if (ans[i].first <= y && y <= ans[i].second){ if (ans[i].first == y){ rec.emplace_back(P(y+1,ans[i].second)); } else if (ans[i].second == y){ rec.emplace_back(P(ans[i].first,y-1)); } else { rec.emplace_back(P(ans[i].first,y-1)); rec.emplace_back(P(y+1,ans[i].second)); } } else rec.emplace_back(ans[i]); } } return rec; } bool ok(vector

a, int x){ int n = a.size(); rep(i,n){ if (range(a[i].first,a[i].second+1,x)) return true; } return false; } int main(){ int n, q; cin >> n >> q; vector

ar(q); rep(i,q) cin >> ar[i].first; rep(i,q) cin >> ar[i].second; rep(i,q) if (ar[i].first > ar[i].second) swap(ar[i].first,ar[i].second); vector

ini = {P(1,n)}; vector> rng(q+1,vector

(0)); rng[0] = ini; rep(i,q){ rng[i+1] = uni(n,rng[i],ar[i].first,ar[i].second); } if (rng[q].size() == 0){ No(); return 0; } Yes(); vector ans(q+1); ans[q] = rng[q][0].first; for (int i = q-1; i >= 0; i--){ int l = ans[i+1] -1; int m = ans[i+1]; int r = ans[i+1] +1; if (ok(rng[i],l)) ans[i] = l; else if (ok(rng[i],m)) ans[i] = m; else ans[i] = r; } rep(i,q+1) cout << ans[i] << endl; /* rep(i,q+1){ rep(j,rng[i].size()){ cout << '[' << rng[i][j].first << " " << rng[i][j].second << "] "; } cout << endl; }*/ }