Advertisement
Guest User

Untitled

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