Cod sursa(job #2756639)

Utilizator dnprxDan Pracsiu dnprx Data 2 iunie 2021 10:26:10
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <bits/stdc++.h>
using namespace std;

bitset<4100>b[4100];
ifstream fin("triplete.in");
ofstream fout("triplete.out");
int n, m;
pair<int, int> a[65600];
int main()
{
    int i, x, y;
    long long cnt = 0;
    fin >> n >> m;
    for (i = 1; i <= m; i++)
    {
        fin >> x >> y;
        if (x > y) swap(x, y);
        a[i].first = x;
        a[i].second = y;
        b[x][y] = 1;
        ///b[y][x] = 1;
    }
    for (i = 1; i <= m; i++)
    {
        x = a[i].first;
        y = a[i].second;
        cnt += (b[x] & b[y]).count();
    }
    fout << cnt << "\n";
    fout.close();
    return 0;
}