Cod sursa(job #2716565)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 5 martie 2021 12:33:19
Problema Triplete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("triplete.in");
ofstream fout("triplete.out");

const int NMAX = 4100;
const int MAXM = 66000;
int N, M;
bitset<NMAX> adj[NMAX];
pair<int,int> edge[MAXM];
long long ans;

int main() {
    fin >> N >> M;
    for(int i = 0; i < M; ++i) {
        fin >> edge[i].first >> edge[i].second;
        adj[edge[i].first][edge[i].second] = adj[edge[i].second][edge[i].first] = true;
    }
    for(int i = 0; i < M; ++i)
        ans += (adj[edge[i].first] & adj[edge[i].second]).count();
    fout << ans / 3 << '\n';
}