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

直接递归模拟,一直WR,悲剧,,,路过的大神帮忙看一下。。。

Posted by bnuep006 at 2010-12-25 19:48:09 on Problem 3768 and last updated at 2010-12-25 19:49:16
我的思路很直观,,,递归直接模拟填图形的过程,但不知道为什么WR,纠结的要命,知道原因的大牛,,顺便提示一下,,,万分感激
求圣诞老人找原因。。。
#include<stdio.h>
#include<math.h>
#include<string.h>
char map[6][6],all[5000][5000],mo[4000][4000];
int n;
void add(int a,int b,int c)
{
    int i,j,x,y;
    x = a;
    for(i = 0;i < c;i++,x++)
    {
        for(j = 0,y = b;j < c;j++,y++)
        {
            all[x][y] = mo[i][j];
        }
    }
}
void dfs(int k,int m)
{
    int i,j;
    if(k <= 1)
        return;
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < n;j++)
        {
            if(map[i][j] != ' ')
            {
                add(i*m,j*m,m);
            }
        }
    }
    for(i = 0;i < m*n;i++)
    {
        for(j = 0;j < m*n;j++)
        {
            mo[i][j] = all[i][j];
        }
    }
    dfs(k - 1,m*n);
}    
int main()
{
    freopen("out.txt","w",stdout);
    int level,stl,i,j,total;
    while(scanf("%d",&n)!= EOF)
    {
        if(n == 0)
            break;
        getchar();
        memset(all,' ',sizeof(all));
        for(i = 0;i < n;i++)
            gets(map[i]);
        for(i = 0;i < n;i++)
        {
            for(j = 0;j < n;j++)
            {
                mo[i][j] = map[i][j];
            }
        }
        scanf("%d",&level);
        dfs(level,n);
        total = (int)pow(n*1.0,level*1.0);
        if(level > 1)
            for(i = 0;i < total;i++)
            {
                all[i][total] = '\0';
                puts(all[i]);
            }
        else if(level == 1)
            for(i = 0;i < total;i++)
            {
                mo[i][total] = '\0';
                puts(mo[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