#include <bits/stdc++.h>
#define ll long long
#define X first
#define Y second
#define MP make_pair
using namespace std;
const int N = 4e5, INF = 1e9 + 7, bl = 300;
int n, k, p[N], clr[N], was[N], ans[N], maxx;
vector<int> g[N], gr[N], topsort, cmp, gg[N];
void dfs(int v){
was[v] = 1;
for(int u: g[v]){
if(!was[u])
dfs(u);
}
topsort.push_back(v);
}
void rdfs(int v){
was[v] = 1;
for(int u: gr[v]){
if(!was[u])
rdfs(u);
}
cmp.push_back(v);
}
void vdfs(int v, int cc = 26){
maxx = max(maxx, 26 - cc + 1);
was[v] = 1, ans[v] = cc;
for(int u: gg[v]){
if(!was[u]){
vdfs(u, max(cc - 1, 1));
}
}
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> p[i];
if(i != 1){
g[p[i]].push_back(p[i - 1]);
gr[p[i - 1]].push_back(p[i]);
}
}
for(int i = 1;i <= n;i++){
cin >> p[i];
if(i != 1){
g[p[i]].push_back(p[i - 1]);
gr[p[i - 1]].push_back(p[i]);
}
}
for(int i = 1;i <= n;i++){
if(!was[i])
dfs(i);
}
vector<int> tt;
reverse(topsort.begin(), topsort.end());
memset(was, 0, sizeof(was));
for(int i = 0, j = 0;i < n;i++){
int v = topsort[i];
if(!was[v]){
cmp.clear();
rdfs(v);
j += 1;
for(int u: cmp){
clr[u] = j;
}
tt.push_back(j);
}
}
for(int i = 1;i <= n;i++){
for(int u: g[i]){
if(clr[i] != clr[u])
gg[clr[i]].push_back(clr[u]);
}
}
memset(was, 0, sizeof(was));
for(int i = 0;i < tt.size();i++){
int v = tt[i];
if(!was[v]){
vdfs(v);
}
}
if(maxx < k)
return cout << "NO", 0;
cout << "YES\n";
for(int i = 1;i <= n;i++){
char c = ans[clr[i]] - 1 + 'a';
cout << c;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CsKgCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgWCB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Sl7CiAgICAgICAgICAgIGdbcFtpXV0ucHVzaF9iYWNrKHBbaSAtIDFdKTsKICAgICAgICAgICAgZ3JbcFtpIC0gMV1dLnB1c2hfYmFjayhwW2ldKTsKICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGkgPSAxO2kgPD0gbjtpKyspewogICAgICAgIGNpbiA+PiBwW2ldOwogICAgICAgIGlmKGkgIT0gMSl7CiAgICAgICAgICAgIGdbcFtpXV0ucHVzaF9iYWNrKHBbaSAtIDFdKTsKICAgICAgICAgICAgZ3JbcFtpIC0gMV1dLnB1c2hfYmFjayhwW2ldKTsKICAgICAgICB9CiAgICB9CiAgICBmb3IoaW50IGkgPSAxO2kgPD0gbjtpKyspewogICAgICAgIGlmKCF3YXNbaV0pCiAgICAgICAgICAgIGRmcyhpKTsKICAgIH0KICAgIHZlY3RvcjxpbnQ+IHR0OwogICAgCiAgICByZXZlcnNlKHRvcHNvcnQuYmVnaW4oKSwgdG9wc29ydC5lbmQoKSk7CiAgICBtZW1zZXQod2FzLCAwLCBzaXplb2Yod2FzKSk7CiAgICBmb3IoaW50IGkgPSAwLCBqID0gMDtpIDwgbjtpKyspewogICAgICAgIGludCB2ID0gdG9wc29ydFtpXTsKICAgICAgICBpZighd2FzW3ZdKXsKICAgICAgICAgICAgY21wLmNsZWFyKCk7CiAgICAgICAgICAgIHJkZnModik7CiAgICAgICAgICAgIGogKz0gMTsKICAgICAgICAgICAgZm9yKGludCB1OiBjbXApewogICAgICAgICAgICAgICAgY2xyW3VdID0gajsKICAgICAgICAgICAgfQogICAgICAgICAgICB0dC5wdXNoX2JhY2soaik7CiAgICAgICAgfQogICAgfQogICAgZm9yKGludCBpID0gMTtpIDw9IG47aSsrKXsKICAgICAgICBmb3IoaW50IHU6IGdbaV0pewogICAgICAgICAgICBpZihjbHJbaV0gIT0gY2xyW3VdKQogICAgICAgICAgICAgICAgZ2dbY2xyW2ldXS5wdXNoX2JhY2soY2xyW3VdKTsKICAgICAgICB9CiAgICB9CiAgICBtZW1zZXQod2FzLCAwLCBzaXplb2Yod2FzKSk7CiAgICBmb3IoaW50IGkgPSAwO2kgPCB0dC5zaXplKCk7aSsrKXsKICAgICAgICBpbnQgdiA9IHR0W2ldOwogICAgICAgIGlmKCF3YXNbdl0pewogICAgICAgICAgICB2ZGZzKHYpOwogICAgICAgIH0KICAgIH0KICAgIAogICAgaWYobWF4eCA8IGspCiAgICAgICAgcmV0dXJuIGNvdXQgPDwgIk5PIiwgMDsKICAgIGNvdXQgPDwgIllFU1xuIjsKICAgIAogICAgZm9yKGludCBpID0gMTtpIDw9IG47aSsrKXsKICAgICAgICBjaGFyIGMgPSBhbnNbY2xyW2ldXSAtIDEgKyAnYSc7CiAgICAgICAgY291dCA8PCBjOwogICAgfQp9
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
^
Main.java:2: error: illegal character: '\u00a0'
?
^
Main.java:3: error: illegal character: '#'
#define ll long long
^
Main.java:4: error: illegal character: '#'
#define X first
^
Main.java:5: error: illegal character: '#'
#define Y second
^
Main.java:6: error: illegal character: '#'
#define MP make_pair
^
Main.java:7: error: illegal character: '\u00a0'
?
^
Main.java:9: error: illegal character: '\u00a0'
?
^
Main.java:10: error: class, interface, or enum expected
const int N = 4e5, INF = 1e9 + 7, bl = 300;
^
Main.java:11: error: illegal character: '\u00a0'
?
^
Main.java:12: error: class, interface, or enum expected
int n, k, p[N], clr[N], was[N], ans[N], maxx;
^
Main.java:13: error: class, interface, or enum expected
vector<int> g[N], gr[N], topsort, cmp, gg[N];
^
Main.java:14: error: illegal character: '\u00a0'
?
^
Main.java:15: error: class, interface, or enum expected
void dfs(int v){
^
Main.java:17: error: class, interface, or enum expected
for(int u: g[v]){
^
Main.java:20: error: class, interface, or enum expected
}
^
Main.java:22: error: class, interface, or enum expected
}
^
Main.java:23: error: illegal character: '\u00a0'
?
^
Main.java:26: error: class, interface, or enum expected
for(int u: gr[v]){
^
Main.java:29: error: class, interface, or enum expected
}
^
Main.java:31: error: class, interface, or enum expected
}
^
Main.java:32: error: illegal character: '\u00a0'
?
^
Main.java:35: error: class, interface, or enum expected
was[v] = 1, ans[v] = cc;
^
Main.java:36: error: class, interface, or enum expected
for(int u: gg[v]){
^
Main.java:39: error: class, interface, or enum expected
}
^
Main.java:42: error: illegal character: '\u00a0'
?
^
Main.java:45: error: class, interface, or enum expected
cin.tie(0);
^
Main.java:46: error: class, interface, or enum expected
cout.tie(0);
^
Main.java:48: error: class, interface, or enum expected
cin >> n >> k;
^
Main.java:49: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:49: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:49: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:51: error: class, interface, or enum expected
if(i != 1){
^
Main.java:53: error: class, interface, or enum expected
gr[p[i - 1]].push_back(p[i]);
^
Main.java:54: error: class, interface, or enum expected
}
^
Main.java:56: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:56: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:58: error: class, interface, or enum expected
if(i != 1){
^
Main.java:60: error: class, interface, or enum expected
gr[p[i - 1]].push_back(p[i]);
^
Main.java:61: error: class, interface, or enum expected
}
^
Main.java:63: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:63: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:66: error: class, interface, or enum expected
}
^
Main.java:69: error: class, interface, or enum expected
reverse(topsort.begin(), topsort.end());
^
Main.java:70: error: class, interface, or enum expected
memset(was, 0, sizeof(was));
^
Main.java:71: error: class, interface, or enum expected
for(int i = 0, j = 0;i < n;i++){
^
Main.java:71: error: class, interface, or enum expected
for(int i = 0, j = 0;i < n;i++){
^
Main.java:71: error: class, interface, or enum expected
for(int i = 0, j = 0;i < n;i++){
^
Main.java:73: error: class, interface, or enum expected
if(!was[v]){
^
Main.java:75: error: class, interface, or enum expected
rdfs(v);
^
Main.java:76: error: class, interface, or enum expected
j += 1;
^
Main.java:77: error: class, interface, or enum expected
for(int u: cmp){
^
Main.java:79: error: class, interface, or enum expected
}
^
Main.java:81: error: class, interface, or enum expected
}
^
Main.java:83: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:83: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:87: error: class, interface, or enum expected
}
^
Main.java:90: error: class, interface, or enum expected
for(int i = 0;i < tt.size();i++){
^
Main.java:90: error: class, interface, or enum expected
for(int i = 0;i < tt.size();i++){
^
Main.java:90: error: class, interface, or enum expected
for(int i = 0;i < tt.size();i++){
^
Main.java:92: error: class, interface, or enum expected
if(!was[v]){
^
Main.java:94: error: class, interface, or enum expected
}
^
Main.java:99: error: class, interface, or enum expected
cout << "YES\n";
^
Main.java:101: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:101: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:101: error: class, interface, or enum expected
for(int i = 1;i <= n;i++){
^
Main.java:103: error: class, interface, or enum expected
cout << c;
^
Main.java:104: error: class, interface, or enum expected
}
^
69 errors