Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int M = 2e5 + 239;
- int n, a;
- ll ans[M];
- unordered_map<int, int> pos;
- int main()
- {
- ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> a;
- ans[i - pos[a]]++;
- pos[a] = i + 1;
- }
- for (pair<int, int> t : pos)
- ans[n - t.second]++;
- for (int it = 0; it < 2; it++)
- for (int i = n - 1; i >= 0; i--)
- ans[i] += ans[i + 1];
- ll cnt = pos.size();
- for (int i = 1; i <= n; i++)
- cout << cnt * (ll)(n - i + 1) - ans[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment