Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> pref(n);
- for (int i = 0; i < n; ++i){
- cin >> pref[i];
- }
- char symb = 'a';
- vector<char> s = {'a'};
- for (int i = 1; i < n; ++i){
- if (pref[i] == pref[i-1] + 1){
- s.emplace_back(s[pref[i-1]]);
- } else {
- if (pref[i] == 0){
- ++symb;
- s.emplace_back(symb);
- } else {
- s.emplace_back(s[pref[i]] - 1);
- }
- }
- }
- for (auto el: s){
- cout << el;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement