-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path617-E-greedy.cpp
53 lines (45 loc) · 982 Bytes
/
617-E-greedy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// problem:
// https://codeforces.com/contest/1296/problem/E1
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <string.h> // memset
#include <algorithm> // lower_bound
#include <iomanip>
// #include <bits/stdc++.h>
using namespace std;
#define fs first
#define sd second
#define pb push_back
#define vii vector<int>
#define pii pair<int, int>
#define MAXN 120000
const int INF = 0x3f3f3f3f;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string s, ans;
char a, b;
cin >> n >> s;
a = s[0];
b = 'a';
ans.push_back('0');
for(int i = 1; i < (int)s.size(); ++i) {
if(s[i] >= a) {
a = s[i];
ans.push_back('0');
} else if(s[i] >= b) {
b = s[i];
ans.push_back('1');
} else {
cout << "NO\n";
return 0;
}
}
cout << "YES\n" << ans << endl;
return 0;
}