CodeChef submission 509539 (C++ 4.3.2) plaintext list. Status: WA, problem MUFFINS, contest . By opethgeek (opethgeek), 2011-04-07 11:51:01.
#include <stdio.h> #include <stdlib.h> int countPossible(int **c, int m, int *cnt, int **mat, int n) { int i, j,k; int min, mi; int count = 0, conf = 0; int *cnt2, x; for(i = 0; i < n; i++) cnt2[i] = cnt[i]; for(i = 0; i < n; i++){ min = 100000; for(j = 0; j < n; j++){ if(cnt[j] < min && cnt > 0){ min = cnt[j]; mi = j; } } conf = 0; for(j = 0; j < cnt[mi]; j++) if(mat[mi][j] == -1) conf = 1; if(!conf) for(j = 0; j < n; j++){ if(cnt[j] != 1000000) for(k = 0; k < cnt[j]; k++){ if(mat[j][k] == mi) mat[j][k] = -1; } } cnt[mi] = 1000000; } for(i = 0; i < n; i++){ conf = 0; for(j = 0; j < cnt2[i]; j++) if(mat[i][j] == -1) conf = 1; if(!conf) count++; } return count; } main() { int i, j, p, count; int n, m, g, gprime; int **c; int **mat; int *cnt; int *conflicting; int x; for(i = 0; i < p; i++){ for(j = 0; j < m; j++) for(j = 0; j < n; j++) conflicting[j] = cnt[j] = 0; for(j = 0; j < m; j++){ cnt[c[j][0]]++; cnt[c[j][1]]++; conflicting[c[j][0]] = conflicting[c[j][1]] = 1; } x = -10000; for(j = 0; j < n; j++) if(cnt[j] > x) x = cnt[j]; for(j = 0; j < n; j++){ cnt[j] = 0; } for(j = 0; j < m; j++){ mat[c[j][0]][cnt[c[j][0]]] = c[j][1]; mat[c[j][1]][cnt[c[j][1]]] = c[j][0]; cnt[c[j][0]]++; cnt[c[j][1]]++; } gprime = 0; for(j = 0; j < n; j++) count += !conflicting[j]; // reduce g by the number of spaces that have no conflict g -= count; if(countPossible(c,m,cnt,mat,n) < g) else } }
Comments

