/* ・wedelinタイプのインスタンスをscpタイプのフォーマットに変換するプログラムです。 ・コンパイルの方法は、 % gcc -O2 -o wedelin2scp wedelin2scp.c です。実行ファイル 'wedelin2scp' ができます。 ・使い方は、 % gunzip -c b727.dat.gz | ./wedelin2scp です。 */ #include #include #include /*** パラメータ *********************************************************/ static int m; /*** 要素数 ***/ static int n; /*** 集合数 ***/ static int **row; /*** i番目の要素が属する集合の番号 ***/ static int **col; /*** j番目の集合に含まれる要素の番号 ***/ static int *cost; /*** j番目の集合の重み ***/ static int *ncol; /*** i番目の要素が属する集合数 ***/ static int *nrow; /*** j番目の集合に含まれる要素数 ***/ /*** 関数 ****************************************************************/ void readscp(void); /*** 問題の読み込み ***/ void output(void); /*** 問題の出力 ***/ void *malloc_e(size_t size); /*** エラー検出付きmalloc関数 ***/ /*** wedelinタイプ問題の読み込み *********************************************/ void readscp(void) { int i,j,k; FILE *fp=stdin; fscanf(fp,"%d",&m); /*** 要素数の読み込み ***/ fscanf(fp,"%d",&n); /*** 集合数の読み込み ***/ /*** 配列の確保 ***/ row=(int **)malloc_e(m*sizeof(int *)); col=(int **)malloc_e(n*sizeof(int *)); cost=(int *)malloc_e(n*sizeof(int)); ncol=(int *)malloc_e(m*sizeof(int)); nrow=(int *)malloc_e(n*sizeof(int)); /*** 問題の読み込み ***/ for(i=0;i