#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include // #include // #include // #include // using namespace __gnu_pbds; // #include // namespace multiprecisioninteger = boost::multiprecision; // using cint=multiprecisioninteger::cpp_int; using namespace std; using ll=long long; #define double long double using datas=pair; using ddatas=pair; using tdata=pair; using vec=vector; using mat=vector; using pvec=vector; using pmat=vector; // using llset=tree,rb_tree_tag,tree_order_statistics_node_update>; #define For(i,a,b) for(i=a;i<(ll)b;++i) #define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i) #define rep(i,N) For(i,0,N) #define rep1(i,N) For(i,1,N) #define brep(i,N) bFor(i,N,0) #define brep1(i,N) bFor(i,N,1) #define all(v) (v).begin(),(v).end() #define allr(v) (v).rbegin(),(v).rend() #define vsort(v) sort(all(v)) #define vrsort(v) sort(allr(v)) #define uniq(v) vsort(v);(v).erase(unique(all(v)),(v).end()) #define endl "\n" #define eb emplace_back #define print(x) cout< ostream& operator<<(ostream& os,const pair& p){return os<<"("< ostream& operator<<(ostream& os,const vector& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< ostream& operator<<(ostream& os,const set& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< inline bool chmax(T& a,T b){bool x=a inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} #ifdef DEBUG void debugg(){cout<void debugg(const T& x,const Args&... args){cout<<" "<0){ if(n&1)res=res*a%m; a=a*a%m; n>>=1; } return res; } ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll countdigits(ll n,ll k=10){ ll ans=0; while(n){n/=k;ans++;} return ans; } ll sumdigits(ll n,ll k=10){ ll ans=0; while(n){ans+=n%k;n/=k;} return ans; } struct scc_graph{ public: scc_graph(int n):_n(n){} scc_graph(vector> g):_n(g.size()){ for(int i=0;i<_n;++i)for(auto& x:g[i])add_edge(i,x); scc_ids(); } scc_graph(vector> g):_n(g.size()){ for(int i=0;i<_n;++i)for(auto& x:g[i])add_edge(i,x); scc_ids(); } void add_edge(int from,int to){ assert(0<=from&&from<_n); assert(0<=to&&to<_n); edges.push_back({from,{to}}); } void add_clause(int i,bool f,int j,bool g){ assert(0<=i&&i*2<_n); assert(0<=j&&j*2<_n); add_edge(i<<1|!f,j<<1|g); add_edge(j<<1|!g,i<<1|f); } //n must be *2 vector solve_twosat(){ if(!group_num)scc_ids(); int m=_n>>1; vector answer(m); for(int i=0;i> scc(){ if(!group_num)scc_ids(); vector counts(group_num); for(auto& x:ids)counts[x]++; vector> groups(group_num); for(int i=0;i start; vector elist; csr(int n,const vector>& edges):start(n+1),elist(edges.size()){ for(auto& e:edges)++start[e.first+1]; for(int i=0;i ids; vector> edges; // @return pair of(# of scc,scc id) void scc_ids(){ auto g=csr(_n,edges); int now_ord=0; vector visited,low(_n),ord(_n,-1); ids.resize(_n); visited.reserve(_n); auto dfs=[&](auto self,int v)-> void{ low[v]=ord[v]=now_ord++; visited.push_back(v); for(int i=g.start[v];i>codeforces;while(codeforces--){ ll i,j; cin>>N>>K; vec v(N); rep(i,N){ cin>>v[i]; --v[i]; } scc_graph fg(K),sg(K); rep1(i,N){ if(i&1){ fg.add_edge(v[i],v[i-1]); sg.add_edge(v[i-1],v[i]); }else{ sg.add_edge(v[i],v[i-1]); fg.add_edge(v[i-1],v[i]); } if((i>=2&&v[i]==v[i-2])||v[i]==v[i-1]){ printno; return 0; } } auto fsol=fg.scc(); if((int)fsol.size()==K){ printyes; vec ans(K); rep(i,K)ans[fsol[i][0]]=i+1; output(ans); }else{ auto ssol=sg.scc(); if((int)ssol.size()==K){ printyes; vec ans(K); rep(i,K)ans[ssol[i][0]]=i+1; output(ans); }else{ printno; } } // } }