Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, point, a[100500], cnt, lvl[100500];
- queue <int> s[100500];
- int main(){
- cin >> n;
- point = -1;
- for(int i = 0; i <= n; i++){
- cin >> a[i];
- if(a[i] > 1 && a[i - 1] > 1){
- cout << "ambigious" << endl;
- point = i;
- }
- }
- if(point == -1){
- cout << "perfect" << endl;
- return 0;
- }
- cnt = 0;
- for(int i = 0; i <= n; i++){
- for(int j = 1; j <= a[i]; j++){
- cnt++;
- s[i].push(cnt);
- lvl[cnt] = i;
- }
- }
- for(int i = 1; i <= cnt; i++){
- cout << lvl[i] << " ";
- }
- cout << endl;
- for(int i = 1; i <= n; i++){
- cout << s[i].front() << " " << s[i].back() << endl;
- }
- cout << endl;
- cout << 0 << " ";
- for(int i = 1; i <= cnt; i++){
- cout << s[lvl[i-1]].back() << " ";
- }
- cout << endl;
- cout << 0 << " ";
- for(int i = 1; i <= cnt; i++){
- int l = lvl[i];
- if(point == l && i == s[l].front())
- {
- cout << s[l].front() << " ";
- }
- else
- cout << s[l].back() << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement