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

就是四条边同时扩张就可以了

Posted by 10041112acmer at 2013-08-19 14:05:25 on Problem 3752
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <stack>
#include <ctime>
#include <list>
using namespace std;

int map[70][70];
int main()
{
    int m,n,i=1,j=1;
    scanf("%d%d",&m,&n);
    memset(map,0,sizeof(map));
    int time=1;
    char c='A';
    map[1][1]='A';
    while(time<m*n)
    {
        while(j+1<=n && !map[i][j+1])
        {
            if(c>=90)
                c-=26;
            map[i][++j]=++c;
            ++time;
        }
        while(i+1<=m && !map[i+1][j])
        {
            if(c>=90)
                c-=26;
            map[++i][j]=++c;
            ++time;
        }

        while(j-1>=1 && !map[i][j-1])
        {
            if(c>=90)
                c-=26;
            map[i][--j]=++c;
            ++time;
        }

        while(i-1>=1 && !map[i-1][j])
        {
            if(c>=90)
                c-=26;
            map[--i][j]=++c;
            ++time;
        }

    }
    for(i=1; i<=m; i++)
    {
        for(j=1; j<=n; j++)
            printf("   %c",map[i][j]);
        printf("\n");
    }
    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