/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 7ms 1.625 MiB
#3 Wrong Answer 7ms 1.621 MiB
#4 Accepted 25ms 808.0 KiB
#5 Accepted 33ms 788.0 KiB
#6 Accepted 33ms 596.0 KiB
#7 Accepted 38ms 584.0 KiB
#8 Accepted 74ms 764.0 KiB
#9 Accepted 52ms 592.0 KiB

Code

#include<bits/stdc++.h>

using namespace std;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define   ll          long long
#define   pb          push_back
#define   F           first
#define   S           second
#define   pII         pair<ll, ll>
#define   all(v)      v.begin(),v.end()
#define   allr(v)     v.rbegin(),v.rend()
#define   Endl        "\n"
#define   Case()      cout<<"Case "<<++cs<<": "
#define   bug(a)      cerr<<#a<<" : "<<a<<endl
#define   Tc()        ll T, cs=0; cin>>T; hell:  while(T--)
#define   Tanmoy      ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0)

const ll Mod=1e9+7, MAX=1e6+10, SZ=2e5+5, N=1e13;
ll a[MAX], b[MAX];

int fx8[]={1, -1, 0, 0, 1, 1, -1, -1};
int fy8[]={0, 0, 1, -1, 1, -1, 1, -1};
int fx4[]={1, -1, 0, 0};
int fy4[]={0, 0, 1, -1};


int main()
{

     Tanmoy;
     ///  freopen("in.txt", "r", stdin);


     Tc(){

         int n, m, ans=0, sum=0;

         cin>>n;

         string s;
         cin>>s;
         map<char, int>mp;

         for(int i=0; i<n; i++){
            mp[s[i]]++;
         }

         for(auto it: mp){
            int x=it.S;
            if(x>0)x--;
            ans+=((x*(x+1))/2);
            ans+=((x*(x+1))/2);
         }
         //ans*=2;

         cout<<ans<<endl;

     }

    return 0;
}





Information

Submit By
Type
Submission
Problem
P1038 Do not touch my string
Contest
Brain Booster #3
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-06 16:08:02
Judged At
2024-10-03 13:50:47
Judged By
Score
80
Total Time
74ms
Peak Memory
1.625 MiB