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

我把主函数去了,就是读入出问题,HELP………………

Posted by rruucc at 2003-11-07 08:55:18 on Problem 1507
In Reply To:这是完整的程序:(RE的) Posted by:rruucc at 2003-11-07 08:53:48
> #include<stdio.h>
> #include<string.h>
> #define MaxN 101
> #define integer short
> 
> int n,l;
> integer map[MaxN][MaxN][MaxN],c[MaxN*MaxN*MaxN];
> int t[MaxN*MaxN*MaxN];
> 
> void swap(integer &a,integer &b)
> { integer c=a;
>  a=b; b=c;
> }
> 
> void init()
> { int i,j,k,x,y,z,tmp;
>  scanf("%d",&n); l=n*n*n;
>  for (i=0; i<n; i++)
>   for (j=0; j<n; j++)
>    for (k=0; k<n; k++)
>     {scanf("%d",&tmp); map[k][j][i]=integer(tmp);
>      if (map[k][j][i]==0) {x=i; y=j; k=z;}
>     }
>  while (x<n-1)
>   {swap(map[x][y][z],map[x+1][y][z]); x++;}
>  while (y<n-1)
>   {swap(map[x][y][z],map[x][y+1][z]); y++;}
>  while (z<n-1)
>   {swap(map[x][y][z],map[x][y][z+1]); z++;}
>  for (i=0; i<l; i++)
>   {j=i; x=j%n;
>    j/=n; y=j%n;
>    j/=n; z=j;
>    c[i]=map[x][y][z];
>   }
> }
> 
> int lowbit(int p)
> {return p&(p^(p-1));}
> 
> int get_t(int s,int e)
> { int p=s,tmp=0;
>  while (p<=e)
>   {tmp+=t[p]; p+=lowbit(p);}
>  return tmp;
> }
> 
> void insert(int p)
> {while (p>=1)
>   {t[p]++; p-=lowbit(p);}
> }
> 
> void search()
> { int i;
>   __int64 d=0;
>  memset(t,0,sizeof(t));
>  for (i=0; i<l-1; i++)
>   {d+=get_t(c[i]+1,l);
>    insert(c[i]);
>   }
>  if (d%2==0) printf("Puzzle can be solved.\n");
>  else printf("Puzzle is unsolvable.\n");
> }
> 
> int main()
> { int testdata,i;
>  scanf("%d",&testdata);
>  for (i=0; i<testdata; i++)
>   {init();
> //   search();
>   }
>  return 0;
> }

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