Guest User

Untitled

a guest
Dec 16th, 2018
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. /*==============================================*\
  2. ID:          shahidul_brur
  3.  
  4. Name:     Md. Shahidul Islam
  5. Study:      CSE, BRUR
  6. Address:  Rangpur, Bangladesh
  7.  
  8.  FB  : fb.com/shahidul.brur
  9.  Blog: shahidul-brur.blogspot.com(in Bengali),
  10.        shahidul-brur-en.blogspot.com(in English)
  11. \*===============================================*/
  12. #include<bits/stdc++.h>
  13. //#include <ext/pb_ds/assoc_container.hpp> // Common file
  14. //#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
  15. //using namespace __gnu_pbds;
  16. using namespace std;
  17. //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
  18.  
  19. typedef long long ll;
  20. typedef unsigned long long ull;
  21. typedef vector<int> vi;
  22. typedef pair<int, int> ii;
  23. typedef pair<ll, int> li;
  24. typedef pair<int, ll> il;
  25. typedef vector<ii> vii;
  26. typedef vector<il> vil;
  27. typedef vector<li> vli;
  28.  
  29. #define ff first
  30. #define ss second
  31. #define pb push_back
  32. #define mp make_pair
  33. #define sz size()
  34. #define all(a)  a.begin(), a.end()
  35. #define mem(a, b)     memset(a, b, sizeof(a))
  36. #define f0(i,b) for(int i=0;i<(b);i++)
  37. #define f1(i,b) for(int i=1;i<=(b);i++)
  38. #define f2(i,a,b) for(int i=(a);i<=(b);i++)
  39. #define fr(i,b,a) for(int i=(b);i>=(a);i--)
  40. #define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
  41.  
  42. int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
  43. int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
  44.  
  45. const double PI = acos(-1.0);
  46. const double EPS = 1e-6;
  47. const int MOD = (int)1e9+7;
  48. const int maxn = (int)2e5+5;
  49. const int LOGN = 20;
  50. int a[maxn], b[maxn];
  51. vi same[maxn];
  52. int main()
  53. {
  54.     ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  55.     //freopen("input.txt", "r", stdin);
  56.     //freopen("output.txt", "w", stdout);
  57.     int n, zero=0, n1=0;
  58.     cin>>n;
  59.     f1(i,n)
  60.     {
  61.         cin>>a[i];
  62.         if(a[i]==0){
  63.             zero++;
  64.         }
  65.         if(a[i]==n-1)
  66.             n1++;
  67.         a[i] = n-a[i];
  68.         same[a[i]].pb(i);
  69.     }
  70.     int id = 0;
  71.     f1(i,n)
  72.     {
  73.         int s = same[i].size();
  74.         if(s==0) continue;
  75.         if(s%i!=0){
  76.             cout << "Impossible\n";
  77.             return 0;
  78.         }
  79.         f0(j,s){
  80.             if(j%i==0) ++id;
  81.             b[same[i][j]] = id;
  82.         }
  83.     }
  84.     cout << "Possible\n";
  85.     f1(i,n) cout << b[i] << " ";
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment