#include using namespace std; #define rep(i,n) for(int i = 0; i < int(n); i++) using ll = long long; using P = pair; bool kadomatsu(ll a, ll b, ll c) { if (a != b && b != c && c != a && (max({a, b, c}) == b || min({a, b, c}) == b)) return true; return false; } bool kadomatsux(vector &a) { rep(i, (int)a.size() - 2) { if (!kadomatsu(a[i], a[i + 1], a[i + 2])) { return false; } } return true; } int main() { int n, m; cin >> n >> m; vector a(n); rep(i, n) { cin >> a[i]; a[i]--; } vector> g(m); vector h(m); rep(i, n - 1) { if (i % 2 == 0) { g[a[i]].push_back(a[i + 1]); h[a[i + 1]]++; } else { g[a[i + 1]].push_back(a[i]); h[a[i]]++; } } // rep(i, m) { // cout << i << " " << h[i] << "=" << " "; // rep(j, g[i].size()) { // cout << g[i][j] << " "; // } // cout << endl; // } stack st; rep(i, m) if (h[i] == 0) st.push(i); vector

ans; while (!st.empty()) { int now = st.top(); st.pop(); ans.push_back({now, ans.size() + 1}); for (auto ne : g[now]) { h[ne]--; if(h[ne] == 0) { st.push(ne); } } } if ((int)ans.size() != m) { cout << "No" << endl; } else { sort(ans.begin(), ans.end()); vector check; rep(i, n) { check.push_back(ans[a[i]].second); } if (!kadomatsux(check)) { cout << "No" << endl; return 0; } cout << "Yes" << endl; rep(i, m) { cout << ans[i].second << " "; } cout << endl; } return 0; }