POJ 2260 Error Correction(水)

题目链接

 枚举一下,就可以。。最近超时的次数太多都怕了。。。SB的忘了个换行PE一次。

 1 #include <stdio.h>

 2 #include <string.h>

 3 int p[101][101],sum1[101],sum2[101],n;

 4 int judge()

 5 {

 6     int i;

 7     for(i = 1;i <= n;i ++)

 8     {

 9         if(sum1[i]%2 != 0)

10         break;

11         if(sum2[i]%2 != 0)

12         break;

13     }

14     if(i == n+1)

15     return 1;

16     else

17     return 0;

18 }

19 int main()

20 {

21     int i,j,z,c,r;

22     while(scanf("%d",&n)!=EOF)

23     {

24         if(n == 0) break;

25         z = 0;

26         memset(sum1,0,sizeof(sum1));

27         memset(sum2,0,sizeof(sum2));

28         for(i = 1;i <= n;i ++)

29         for(j = 1;j <= n;j ++)

30         scanf("%d",&p[i][j]);

31         for(i = 1;i <= n;i ++)

32         {

33             for(j = 1;j <= n;j ++)

34             sum1[i] += p[i][j];

35         }

36         for(i = 1;i <= n;i ++)

37         for(j = 1;j <= n;j ++)

38         {

39             sum2[j] += p[i][j];

40         }

41         if(judge())

42         {

43             printf("OK\n");

44         }

45         else

46         {

47             for(i = 1;i <= n&&z == 0;i ++)

48             for(j = 1;j <= n&&z == 0;j ++)

49             {

50                 sum1[i]++;

51                 sum2[j]++;

52                 if(judge())

53                 {

54                     z = 1;

55                     c = i;

56                     r = j;

57                 }

58                 sum1[i]--;

59                 sum2[j]--;

60             }

61             if(z)

62             printf("Change bit (%d,%d)\n",c,r);

63             else

64             printf("Corrupt\n");

65         }

66     }

67     return 0;

68 }

 

 

你可能感兴趣的:(error)