Cod sursa(job #2907370)

Utilizator SeracovanuEdwardSeracovanu Edward SeracovanuEdward Data 29 mai 2022 23:04:06
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <bits/stdc++.h>

using namespace std;

int const nmax = 4096 + 5;

int n , m;

vector <pair<int,int>> v;
bitset<nmax> priet[nmax];


int main()
{
    freopen("triplete.in","r",stdin);
    freopen("triplete.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m;
    for(int i = 1;i <= m; ++i){
        int x , y;
        cin >> x >> y;
        v.push_back({x,y});
        priet[x][y] = priet[y][x] = 1;
    }
    long long int ans = 0;
    for(int i = 1;i <= m; ++i){
        bitset<nmax> comun = priet[v[i-1].first] & priet[v[i-1].second];
        ans += comun.count();
    }
    cout << ans / 3;
}