Test instructions: To a graph with no direction, the correlation matrix of this graph is a. It then computes the and of all the elements in the ATA matrix.
Idea: If the matrix to find out, space is not able to withstand, the amount of data is too large. All we ask for is the and of the various elements of ATA. Look at the correlation matrix, you can find that, for the two vertices without edges, the contribution of this edge to the result is the degree of the two vertices, so only need to scan each edge, and then add the appearance of the degree of the vertex can be.
#include <iostream> #include <stdio.h> #include <cmath> #include < ;algorithm> #include <iomanip> #include <cstdlib> #include <STRING&G
T #include <memory.h> #include <vector> #include <queue> #include < stack> #include <map> #include <set> #include <ctype.h> #define LL Lo
ng Long #define MAX3 (A,B,C) max (A,max (b,c)) using namespace Std;
int edge[100010][2];
int cnt[10010];
int main () {int n,m;
while (cin>>n>>m) {memset (cnt,0,sizeof (CNT));
for (int i=1;i<=m;i++) {int u,v;
scanf ("%d%d", &u,&v);
Edge[i][0]=u;
Edge[i][1]=v;
cnt[u]++;
cnt[v]++;
} ll Ans=0; for (int i=1;i<=m;i++) {ans+=cnt[edge[i][0]];
ANS+=CNT[EDGE[I][1]];
} cout<<ans<<endl;
} return 0; }