接下來m行,每行兩個整數a、b,表示圖中有(a,b)邊。
注意圖中可能含有重邊,但不會有自環。
1 2
3 1
1 5
2 5
2 3
2 3
3 2
4 3
5 4
-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
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int[][] temp = new int[105][1005];
for (int i = 1; i <=m; i++) {
int a = in.nextInt();
int b = in.nextInt();
temp[a][i] = 1;
temp[b][i] = -1;
}
for (int i = 1; i <=n; i++) {
System.out.print(temp[i][1] + " ");
for (int j = 2; j <=m; j++) {
System.out.print(temp[i][j] + " ");
}
System.out.println();
}
}
}