PersonalCorpus 版 (精华区)

Your C++ program has solved Ok the problem 10102 (The path in the 
colored field)
in 0.740 seconds using as much as 436 kbytes of virtual memory.

void main()
{
    int i,j,k,n,a,b,c,best;
    char map[200][200];

    while (scanf("%d\n",&n)==1) {
        for (i=0;i<n;i++) gets(map[i]);
        best=0;
        for (i=0;i<n;i++) for (j=0;j<n;j++) if (map[i][j]=='1') {
            c=100000000;
            for (a=0;a<n;a++) for (b=0;b<n;b++) if (map[a][b]=='3') {
                k=abs(a-i)+abs(b-j);
                if (k<c) c=k;
            }
            if (c>best) best=c;
        }
        printf("%d\n",best);
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.061毫秒