Advertisement
askarulytarlan

c

Jan 2nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, point, a[100500], cnt, lvl[100500];
  6. queue <int> s[100500];
  7.  
  8. int main(){
  9. cin >> n;
  10. point = -1;
  11. for(int i = 0; i <= n; i++){
  12. cin >> a[i];
  13. if(a[i] > 1 && a[i - 1] > 1){
  14. cout << "ambigious" << endl;
  15. point = i;
  16. }
  17. }
  18. if(point == -1){
  19. cout << "perfect" << endl;
  20. return 0;
  21. }
  22. cnt = 0;
  23. for(int i = 0; i <= n; i++){
  24. for(int j = 1; j <= a[i]; j++){
  25. cnt++;
  26. s[i].push(cnt);
  27. lvl[cnt] = i;
  28. }
  29. }
  30. for(int i = 1; i <= cnt; i++){
  31. cout << lvl[i] << " ";
  32. }
  33. cout << endl;
  34. for(int i = 1; i <= n; i++){
  35. cout << s[i].front() << " " << s[i].back() << endl;
  36. }
  37. cout << endl;
  38. cout << 0 << " ";
  39. for(int i = 1; i <= cnt; i++){
  40. cout << s[lvl[i-1]].back() << " ";
  41. }
  42. cout << endl;
  43. cout << 0 << " ";
  44. for(int i = 1; i <= cnt; i++){
  45. int l = lvl[i];
  46. if(point == l && i == s[l].front())
  47. {
  48. cout << s[l].front() << " ";
  49. }
  50. else
  51. cout << s[l].back() << " ";
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement