Salvens

Untitled

Jan 11th, 2024
1,052
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. const int M = 2e5 + 239;
  8.  
  9. int n, a;
  10. ll ans[M];
  11. unordered_map<int, int> pos;
  12.  
  13. int main()
  14. {
  15.     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  16.     cin >> n;
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         cin >> a;
  20.         ans[i - pos[a]]++;
  21.         pos[a] = i + 1;
  22.     }
  23.     for (pair<int, int> t : pos)
  24.         ans[n - t.second]++;
  25.     for (int it = 0; it < 2; it++)
  26.         for (int i = n - 1; i >= 0; i--)
  27.             ans[i] += ans[i + 1];
  28.     ll cnt = pos.size();
  29.     for (int i = 1; i <= n; i++)
  30.         cout << cnt * (ll)(n - i + 1) - ans[i] << " ";
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment