Advertisement
erfanul007

Untitled

Jan 13th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int> pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define pb push_back
  14. #define pob pop_back
  15. #define mp make_pair
  16. #define ff first
  17. #define ss second
  18. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  19. #define loop(i,y) for(int i=0; i<int(y); i++)
  20. #define rloop(i,y) for(int i=int(y); i>0; i--)
  21. #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
  22. #define read() freopen("input.txt", "r", stdin)
  23. #define write() freopen("output.txt", "w", stdout)
  24. #define cspf(i) printf("Case %d: ", i)
  25. #define all(v) v.begin(),v.end()
  26. /// Constants
  27. #define eps 1e-9
  28. #define PI acos(-1.0) // 3.1415926535897932
  29.  
  30. int main()
  31. {
  32. int n,z;
  33. cin>>n;
  34. int a[n+1],x[n+1],flg[n+1];
  35. loop(i,n){
  36. a[i]=0;
  37. flg[i]=0;
  38. }
  39. z=0;
  40. loop(i,n){
  41. cin>>x[i];
  42. a[x[i]]++;
  43. if(flg[x[i]]==0){
  44. z++;
  45. flg[x[i]]=z;
  46. }
  47. }
  48. loop(i,n){
  49. if(a[x[i]]==n ){
  50. if(x[i]==n-1){
  51. cout<<"Possible"<<endl;
  52. loop1(j,n){
  53. cout<<j;
  54. if(j<n)
  55. cout<<" ";
  56. }
  57. cout<<endl;
  58. return 0;
  59. }
  60. else if(x[i]==0){
  61. cout<<"Possible"<<endl;
  62. loop1(j,n){
  63. cout<<"1";
  64. if(j<n)
  65. cout<<" ";
  66. }
  67. cout<<endl;
  68. return 0;
  69. }
  70. else
  71. cout<<"Impossible"<<endl;
  72. return 0;
  73. }
  74. z=n-a[x[i]];
  75. if(z!=x[i]){
  76. cout<<"Impossible"<<endl;
  77. return 0;
  78. }
  79. }
  80. cout<<"Possible"<<endl;
  81. loop(i,n){
  82. cout<<flg[x[i]];
  83. if(i+1<n)
  84. cout<<" ";
  85. }
  86. cout<<endl;
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement