tuki2501

bedao_r03_kindness.cpp

Nov 28th, 2021 (edited)
498
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. signed main() {
  7.   cin.tie(0)->sync_with_stdio(0);
  8.   string s; cin >> s;
  9.   int n = s.size();
  10.   ll ans = (ll) n * (n - 1) / 2;
  11.   map<char, int> cnt;
  12.   for (int i = 0; i < n; i++) {
  13.     ans -= cnt[s[i]];
  14.     cnt[s[i]]++;
  15.   }
  16.   cout << ans + (int)(cnt.size() < n) << '\n';
  17. }
  18.  
RAW Paste Data