Cod sursa(job #2919549)

Utilizator tiwerlolPop Iuliu-Daniel tiwerlol Data 18 august 2022 04:11:05
Problema Litere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#include <map>
#include <climits>
#include <math.h>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

#define ll long long
#define ull unsigned long long

#define forc(n) for(int i = 0; i < n; ++i)
#define ford(n) for(int i = 1; i <= n; ++i)

#define ajutor ios_base::sync_with_stdio(false);
#define pls cin.tie(nullptr); cout.tie(nullptr)

ofstream cout("litere.out");
ifstream cin("litere.in");

char v[10001];

int main()
{
    int n; cin >> n;
    cin >> v;
    ll cnt = 0;
    map<char, int> mp;

    for(int z = 0; v[z] != 0; z++)
    {
        mp[v[z]]++;
        for(int x = v[z]+1; x <= 'z'; x++)
        {
            cnt += mp[char(x)];
        }
    }
    cout << cnt;
}