Cod sursă (job #800076)

Utilizator avatar Dumy Dumitrescu Andrei Dumy IP ascuns
Problemă Cristela (clasele 9-12) Compilator cpp-32 | 0,53 kb
Rundă Arhiva de probleme Status evaluat
Dată 16 dec. 2024 09:56:43 Scor 15
#include <fstream>
#include <string>

using namespace std;

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

int v[500000];

int main()
{
    ios::sync_with_stdio(false);

    int n; string s;
    cin>>n;

    for(int i=0; i<n; i++)
    {
        cin>>s;

        for(int j=0; j<s.length(); j++)
        {
            v[i] |= (1<<(s[j]-'a'));
        }
    }
    int c=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n ;j ++)
        {
            if((v[i]&v[j])!=0)
                c++;
        }
    }
    cout<<c;
}