#include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; bool topological_sort(vector> g, vector &order){ int n = g.size(); order.clear(); vector used(n, false); function dfs = [&](int v){ used[v] = true; for(int to : g[v]){ if(!used[to]) dfs(to); } order.push_back(v); }; for(int v = 0; v < n; v++){ if(!used[v]) dfs(v); } reverse(order.begin(), order.end()); vector inv_order(n); for(int i = 0; i < n; i++) inv_order[order[i]] = i; for(int v = 0; v < n; v++){ for(int u : g[v]){ if(inv_order[v] > inv_order[u]) return false; } } return true; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, m; cin >> n >> m; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; a[i]--; } vector> g(m); for(int i = 0; i < n-1; i++){ if(a[i] == a[i+1]){ cout << "No" << endl; return 0; } if(i < n-2 && a[i] == a[i+2]){ cout << "No" << endl; return 0; } if(i%2 == 0){ g[a[i]].push_back(a[i+1]); }else{ g[a[i+1]].push_back(a[i]); } } vector tsort; if(!topological_sort(g, tsort)){ cout << "No" << endl; return 0; } cout << "Yes" << endl; vector ans(m); for(int i = 0; i < m; i++) ans[tsort[i]] = i+1; for(int x : ans) cout << x << ' '; cout << endl; }