Algorithm training correlation matrix time limit: 1.0s memory limit: 512.0MBThe problem description has a forward graph of n nodes m edges, please output his correlation matrix. Input format the first line two integers n, m, indicating the number of nodes and edges in the graph. n<=100,m<=1000.
Next m line, two integers a, b for each line, indicates that there are (b) edges in the diagram.
Note that the image may contain a heavy edge, but there is no self-loop. Output format output the graph's correlation matrix, and be careful not to change the order of edges and nodes. Sample Input 5 9
0 S
3 1
1 5
2 5
2 3
2 3
3 2
4 3
5 4 Sample Output 1-1 1 0 0 0 0 0 0
-1 0 0 1 1 1-1 0 0
0 1 0 0-1-1 1-1 0
0 0 0 0 0 0 0 1-1
0 0-1-1 0 0 0 0 1
#include <iostream>#include<cstdio>#include<algorithm>#include<cstdlib>#definefor (i,x,n) for (int i=x;i<n;i++)#definell Long Long intusing namespacestd;inta[ the][1005]={0};intMain () {intM,n; intx, y; scanf ("%d%d",&n,&m); forI0, M) {scanf ("%d%d",&x,&y); A[x][i]=1; A[y][i]=-1; } forI1, n+1){ for(J,0, M) {printf ("%d", A[i][j]); } printf ("\ n"); } return 0;}
Algorithm Training Correlation Matrix