#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(),(x).end() #define inf 1e18 using namespace std; typedef long long llint; typedef long long ll; typedef pair P; struct SCC{ int n; vector > G, revG, compG; vector used, scc, topo; int sccid, sccnum; void tpdfs(int v) { used[v] = 1; for(int i = 0; i < G[v].size(); i++){ if(!used[G[v][i]]) tpdfs(G[v][i]); } topo.push_back(v); } void sccdfs(int v, int id) { used[v] = 1; scc[v] = id; for(int i = 0; i < revG[v].size(); i++){ if(!used[revG[v][i]]) sccdfs(revG[v][i], id); } } SCC(){} SCC(int n){ //V(G) = {1, 2, ..., n}, nを制約より大きくするときは注意 this->n = n; G.resize(n+1); revG.resize(n+1); used.resize(n+1); } void init(){ for(int i = 1; i <= n; i++){ G[i].clear(), revG[i].clear(); used[i] = 0; } topo.clear(); } void add_edge(int u, int v) { G[u].push_back(v); } void tpsort() { topo.clear(); for(int i = 1; i <= n; i++) used[i] = 0; for(int i = 1; i <= n; i++) if(!used[i]) tpdfs(i); reverse(topo.begin(), topo.end()); } bool checkDAG(){ //先にtpsort()を呼ぶべし。DAGならtrueを返す for(int i = 1; i <= n; i++) used[i] = 0; for(int i = 0; i < topo.size(); i++){ int v = topo[i]; used[v] = 1; for(int j = 0; j < G[v].size(); j++){ if(used[G[v][j]]) return false; } } return true; } int calcSCC(){ //先にtpsort()を呼ぶべし。戻り値はSCCの個数。SCC-IDは1-indexed scc.resize(n+1); for(int i = 1; i <= n; i++) revG[i].clear(); for(int i = 1; i <= n; i++){ for(int j = 0; j < G[i].size(); j++){ revG[G[i][j]].push_back(i); } } sccid = 1; for(int i = 1; i <= n; i++) used[i] = 0; for(int i = 0; i < topo.size(); i++) if(!used[topo[i]]) sccdfs(topo[i], sccid++); return sccnum = sccid-1; } void compressSCC(bool simple = false){ //先にcalcSCC()を呼ぶべし。圧縮後のグラフはscc::compG compG.resize(sccnum+1); for(int i = 1; i <= n; i++){ for(int j = 0; j < G[i].size(); j++){ int u = G[i][j]; if(scc[i] != scc[u]) compG[scc[i]].push_back(scc[u]); } } if(simple){ for(int i = 1; i <= sccnum; i++){ sort(compG[i].begin(), compG[i].end()); compG[i].erase(unique(compG[i].begin(), compG[i].end()), compG[i].end()); } } } }; ll n, m; ll a[100005]; ll ans[100005]; bool check(ll a, ll b, ll c) { if(a == b || b == c || c == a) return false; if(a > b && b < c) return true; if(a < b && b > c) return true; return false; } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; rep(i, 1, n) cin >> a[i]; rep(i, 2, n-1){ if(a[i-1] == a[i+1]){ cout << "No" << endl; return 0; } } SCC scc(m); rep(i, 1, n-1){ if(i % 2) scc.add_edge(a[i], a[i+1]); else scc.add_edge(a[i+1], a[i]); } scc.tpsort(); if(scc.checkDAG()){ rep(i, 0, m-1) ans[scc.topo[i]] = i+1; cout << "Yes" << endl; rep(i, 1, m) cout << ans[i] << " "; cout << endl; return 0; } scc.init(); rep(i, 1, n-1){ if(i % 2 == 0) scc.add_edge(a[i], a[i+1]); else scc.add_edge(a[i+1], a[i]); } scc.tpsort(); if(scc.checkDAG()){ rep(i, 0, m-1) ans[scc.topo[i]] = i+1; cout << "Yes" << endl; rep(i, 1, m) cout << ans[i] << " "; cout << endl; return 0; } cout << "No" << endl; return 0; }