我们可以从前往后扫一遍,对于后面的字母,如果比当前字母小,则染成相反的颜色,如果比当前字母小且颜色和当前颜色相同,则说明不符合条件
#include<bits/stdc++.h>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x++)
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef pair<char,char> PCC;
typedef long long ll;
const int N=205;
const int M=1e6+10;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
/*注意边界
清空每个case的影响
注意数据范围
注意证明*/
int ans[205];
void solve(){
mst(ans,-1);
int n;cin>>n;
string s;cin>>s;
rep(i,0,sz(s)){
if(ans[i]==-1) ans[i]=0;
rep(j,i+1,sz(s)){
if(s[j]<s[i]){
if(ans[j]==-1) ans[j]=ans[i]^1;
else if(ans[j]==ans[i]){
cout<<"NO"<<endl;
return;
}
}
}
}
cout<<"YES"<<endl;
rep(i,0,sz(s)) cout<<ans[i];
cout<<endl;
}
int main(){
IOS;
//int t;cin>>t;
//while(t--)
solve();
return 0;
}