/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 404.0 KiB
#2 Accepted 7ms 1.465 MiB
#3 Accepted 7ms 1.465 MiB
#4 Accepted 25ms 800.0 KiB
#5 Accepted 35ms 696.0 KiB
#6 Accepted 38ms 600.0 KiB
#7 Accepted 42ms 560.0 KiB
#8 Accepted 63ms 580.0 KiB
#9 Accepted 40ms 596.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
using ll = long long;

int main() {
  FAST;
  
  int tc = 1, ti;
  cin >> tc;

  for (ti = 1; ti <= tc; ++ti) {
    ll n, ans;
    string s;
    cin >> n >> s;

    map<char,ll> mp;
    for (char c : s) mp[c] += 1;

    ans = 0;
    for (auto [_, cnt] : mp) ans += cnt*(cnt-1);

    cout << ans << "\n";
  }

  return 0;
}

Information

Submit By
Type
Submission
Problem
P1038 Do not touch my string
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 20:23:54
Judged At
2024-11-11 02:44:31
Judged By
Score
100
Total Time
63ms
Peak Memory
1.465 MiB