Advertisement
Kali_prasad

print freq of elements which are in range(1,N) with complexity N,1

Apr 22nd, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3.  
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8. typedef pair<int, int> pii;
  9. typedef pair<string,int> psi;
  10. typedef unordered_map<int,int> mii;
  11. typedef unordered_map<long long,long long> mll;
  12. typedef unordered_map<string,int> msi;
  13. typedef unordered_map<char,int> mci;
  14. typedef unordered_set<int> si;
  15. typedef unordered_set<long long> sll;
  16. typedef unordered_set<string> ss;
  17. typedef unordered_set<char> sc;
  18. typedef map<int,int> ormii;
  19. typedef map<long long,long long> ormll;
  20. typedef map<string,int> ormsi;
  21. typedef map<char,int> ormci;
  22. typedef set<int> orsi;
  23. typedef set<long long> orsll;
  24. typedef set<string> orss;
  25. typedef set<char> orsc;
  26. typedef vector<int> vi;
  27. typedef vector<string> vs;
  28. typedef vector<char> vc;
  29. typedef vector<ll> vll;
  30. typedef vector<vector<int>> vvi;
  31. typedef vector<vector<string>> vvs;
  32. typedef vector<vector<ll>> vvll;
  33.  
  34. #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
  35. #define FORd(i,b,a) for (int i =b; i >= a; i--)
  36. #define sz(x) (int)(x).size()
  37. #define mp make_pair
  38. #define pb push_back
  39. #define pob pop_back
  40. #define fi first
  41. #define se second
  42. #define ins insert
  43.  
  44. const int MOD = 1000000007;
  45. //type functions here
  46.  
  47. /*
  48. Data set
  49. vi v={3 ,5, 8, 3, 1, 5, 5 ,10, 5 ,10, 2, 3};
  50. */
  51.  
  52. int main() {
  53.     ios_base::sync_with_stdio(false);
  54.     cin.tie(NULL);
  55.    
  56.     int tc=1;
  57.     //cin>>tc;
  58.     FOR(w,1,tc)
  59.     {
  60.       vi v={3 ,5, 8, 3, 1, 5, 5 ,10, 5 ,10, 2, 3};
  61.       int n=v.size();
  62.       FOR(i,0,n-1)
  63.       {
  64.           v[v[i]%(n+1)-1]+=(n+1);
  65.       }
  66.       FOR(i,1,n)
  67.       {
  68.           int temp=v[i-1]/(n+1);
  69.           cout<<i<<" "<<temp<<endl;
  70.       }
  71.      
  72.     }
  73.     return 0;
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement