Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:求救啊,所有所谓官方测试数据都过了。 WAAAA~~~~

Posted by zhangyehui at 2010-02-05 22:47:08 on Problem 1753
In Reply To:求救啊,所有所谓官方测试数据都过了。 WAAAA~~~~ Posted by:fanjianjin at 2010-02-02 00:46:36
> 我这是直接二进制串枚举
> 
> #include<stdio.h>
> #include<stdlib.h>
> #include<memory.h>
> #include<string.h>
> char b[100];
> void bin(int x)
> {
>     int n=x;
>     while (n>0)
>     {
>           if (n%2==0) strcat(b,"0");else strcat(b,"1");
>           n=n/2;
>     }
>     while (strlen(b)<16) strcat(b,"0");
> }
> main()
> {
>       char s[5][10],t[5][10],p[5],c;
>       int i,j,k,l,m,n,x,y,f1,f2,stp,min;
>       memset(s,0,sizeof(s));
>       for (i=0;i<4;i++)
>       { 
>         for (j=0;j<4;j++)
>           s[i][j]=getchar();
>         c=getchar();
>       }
>       min=100000;
>       for (i=0;i<=65536;i++)
>       {
>           memset(t,0,sizeof(t));
>           strcpy(t[0],s[0]);
>           strcpy(t[1],s[1]);
>           strcpy(t[2],s[2]);
>           strcpy(t[3],s[3]);
>           memset(b,0,sizeof(b));
>           bin(i);
>           stp=0;
>           for (j=0;j<strlen(b);j++)
>           {
>             if (b[j]=='1')
>             {
>                    stp++;
>                    x=j/4;y=j%4;
>                    if (t[x][y]=='w') t[x][y]='b';else t[x][y]='w';
>                    if (t[x-1][y]=='w' && x-1>=0) t[x-1][y]='b';else t[x-1][y]='w';
>                    if (t[x+1][y]=='w' && x+1<4) t[x+1][y]='b';else t[x+1][y]='w';
>                    if (t[x][y+1]=='w' && y+1<4) t[x][y+1]='b';else t[x][y+1]='w';
>                    if (t[x][y-1]=='w' && y-1>=0) t[x][y-1]='b';else t[x][y-1]='w';
>                    
>             } 
>           }
>           
>           c=t[0][0];
>           f1=0;
>           for (j=0;j<4;j++)
>             for (k=0;k<4;k++)
>               if (t[j][k]!=c)
>               {
>                   f1=1;break;
>               }
>           if (!f1 && stp<min) min=stp; 
>       }      
>       if (min==100000) printf("Impossible\n");
>       else printf("%d\n",min);
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator