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

空行考虑了 和SAMPLE一个样 就是WA 为啥啊

Posted by frankyoyo at 2010-04-14 21:39:26 on Problem 2488
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int visit[60][60];
int z[60];
char h[60];
int a,b;
int ct=0;
int p=0;
int q=0;
void dfs(int x,int y){
    if (x<1 || x>a ||y<1||y>b||visit[x][y]==1||ct==a*b)
        {return;}
    else{
    ct++;
    visit[x][y]=1;
    h[p++]=y+'A'-1;
    z[q++]=x;
    dfs(x-1,y-2);
    dfs(x+1,y-2);
    dfs(x-2,y-1);
    dfs(x+2,y-1);
    dfs(x-2,y+1);
    dfs(x+2,y+1);
    dfs(x-1,y+2);
    dfs(x+1,y+2);
    }
}
int main()
{
    int k,i;
    int t;
    scanf("%d",&t);
     i=1;
    while (t--){
     ct=0;
     p=0;
     q=0;
     memset(h,0,sizeof(h));
     memset(z,0,sizeof(z));
     memset(visit,0,sizeof(visit));
     scanf ("%d%d",&a,&b);
     printf("Scenario #%d:\n",i);
     dfs(1,1);
     if (ct==a*b){
     for (k=0;k<a*b;k++){
     printf("%c%d",h[k],z[k]);
        }
     }
     if (ct!=a*b) {printf("impossible");}
     if (t!=0) {printf("\n\n");}
     if (t==0) {printf("\n");}
     i++;
    }
    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